body请求支持更多中类型
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat;
|
||||
package cn.wenat;
|
||||
|
||||
public interface CallListener {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat;
|
||||
package cn.wenat;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.util.HashMap;
|
||||
@@ -14,9 +14,9 @@ import org.json.JSONException;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.wezoz.nat.form.MainForm;
|
||||
import com.wezoz.nat.utils.HttpClientUtils;
|
||||
|
||||
import cn.wenat.form.MainForm;
|
||||
import cn.wenat.utils.HttpClientUtils;
|
||||
import io.socket.client.IO;
|
||||
import io.socket.client.IO.Options;
|
||||
import io.socket.client.Socket;
|
||||
@@ -239,7 +239,7 @@ public class LocalServer {
|
||||
response = HttpClientUtils.post(post, params);
|
||||
}else {
|
||||
//其他的全部postBody
|
||||
response = HttpClientUtils.postBody(post, request.getString("params"), encoding);
|
||||
response = HttpClientUtils.postBody(post, request.getString("body"), encoding);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response = new Response();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat;
|
||||
package cn.wenat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat;
|
||||
package cn.wenat;
|
||||
|
||||
import io.socket.emitter.Emitter.Listener;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat.form;
|
||||
package cn.wenat.form;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.WindowAdapter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat.form;
|
||||
package cn.wenat.form;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -18,8 +18,8 @@ import javax.swing.JTextField;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import com.wezoz.nat.CallListener;
|
||||
import com.wezoz.nat.LocalServer;
|
||||
import cn.wenat.CallListener;
|
||||
import cn.wenat.LocalServer;
|
||||
|
||||
public class MainForm extends BaseForm {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MainForm extends BaseForm {
|
||||
try {
|
||||
String host = txtHost.getText();
|
||||
server = new LocalServer();
|
||||
server.setServer("http://wezoz.com:3001");
|
||||
server.setServer("http://127.0.0.1:3001");
|
||||
server.setForward(host);
|
||||
server.setDomain(txtDomain.getText());
|
||||
server.setCallListener(new CallListener() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat.utils;
|
||||
package cn.wenat.utils;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -48,7 +48,8 @@ import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.wezoz.nat.Response;
|
||||
|
||||
import cn.wenat.Response;
|
||||
|
||||
/**
|
||||
* http请求工具 httpclient4.5
|
||||
@@ -205,7 +206,9 @@ public class HttpClientUtils {
|
||||
public static Response postBody(HttpPost httpPost, String body,String encoding) {
|
||||
Response res = null;
|
||||
try {
|
||||
httpPost.setEntity(new StringEntity(body, encoding));
|
||||
StringEntity entity=new StringEntity(body,encoding);
|
||||
// entity.setContentType(httpPost.getFirstHeader("content-type"));
|
||||
httpPost.setEntity(entity);
|
||||
CloseableHttpResponse response = getClient().execute(httpPost);
|
||||
res = getContent(response);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.wezoz.nat.utils;
|
||||
package cn.wenat.utils;
|
||||
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
Reference in New Issue
Block a user