body请求支持更多中类型
This commit is contained in:
@@ -2,14 +2,16 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.wezoz.nat</groupId>
|
<groupId>com.wenat</groupId>
|
||||||
<artifactId>wezoz-nat-client</artifactId>
|
<artifactId>wenat-client</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>wezoz-nat-client</name>
|
<name>wenat-client</name>
|
||||||
<url>https://www.wezoz.com</url>
|
<url>https://www.wezoz.com</url>
|
||||||
|
<description>
|
||||||
|
wenat.cn 这个域名没备案,.com的域名将就用吧~
|
||||||
|
</description>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat;
|
package cn.wenat;
|
||||||
|
|
||||||
public interface CallListener {
|
public interface CallListener {
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat;
|
package cn.wenat;
|
||||||
|
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -14,9 +14,9 @@ import org.json.JSONException;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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;
|
||||||
import io.socket.client.IO.Options;
|
import io.socket.client.IO.Options;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
@@ -239,7 +239,7 @@ public class LocalServer {
|
|||||||
response = HttpClientUtils.post(post, params);
|
response = HttpClientUtils.post(post, params);
|
||||||
}else {
|
}else {
|
||||||
//其他的全部postBody
|
//其他的全部postBody
|
||||||
response = HttpClientUtils.postBody(post, request.getString("params"), encoding);
|
response = HttpClientUtils.postBody(post, request.getString("body"), encoding);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
response = new Response();
|
response = new Response();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat;
|
package cn.wenat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat;
|
package cn.wenat;
|
||||||
|
|
||||||
import io.socket.emitter.Emitter.Listener;
|
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.Color;
|
||||||
import java.awt.event.WindowAdapter;
|
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.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -18,8 +18,8 @@ import javax.swing.JTextField;
|
|||||||
import javax.swing.border.EtchedBorder;
|
import javax.swing.border.EtchedBorder;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import com.wezoz.nat.CallListener;
|
import cn.wenat.CallListener;
|
||||||
import com.wezoz.nat.LocalServer;
|
import cn.wenat.LocalServer;
|
||||||
|
|
||||||
public class MainForm extends BaseForm {
|
public class MainForm extends BaseForm {
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class MainForm extends BaseForm {
|
|||||||
try {
|
try {
|
||||||
String host = txtHost.getText();
|
String host = txtHost.getText();
|
||||||
server = new LocalServer();
|
server = new LocalServer();
|
||||||
server.setServer("http://wezoz.com:3001");
|
server.setServer("http://127.0.0.1:3001");
|
||||||
server.setForward(host);
|
server.setForward(host);
|
||||||
server.setDomain(txtDomain.getText());
|
server.setDomain(txtDomain.getText());
|
||||||
server.setCallListener(new CallListener() {
|
server.setCallListener(new CallListener() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat.utils;
|
package cn.wenat.utils;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -48,7 +48,8 @@ import org.apache.http.message.BasicNameValuePair;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.wezoz.nat.Response;
|
|
||||||
|
import cn.wenat.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http请求工具 httpclient4.5
|
* http请求工具 httpclient4.5
|
||||||
@@ -205,7 +206,9 @@ public class HttpClientUtils {
|
|||||||
public static Response postBody(HttpPost httpPost, String body,String encoding) {
|
public static Response postBody(HttpPost httpPost, String body,String encoding) {
|
||||||
Response res = null;
|
Response res = null;
|
||||||
try {
|
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);
|
CloseableHttpResponse response = getClient().execute(httpPost);
|
||||||
res = getContent(response);
|
res = getContent(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.wezoz.nat.utils;
|
package cn.wenat.utils;
|
||||||
|
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|||||||
Reference in New Issue
Block a user