|
@@ -49,10 +49,11 @@ public class HttpUtil {
|
|
* @param json
|
|
* @param json
|
|
* @param secret
|
|
* @param secret
|
|
* @param timestamp
|
|
* @param timestamp
|
|
|
|
+ * @param encode
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static String postJson(String url, String json, String secret, Long timestamp) throws IOException {
|
|
|
|
|
|
+ public static String postJson(String url, String json, String secret, Long timestamp, boolean encode) throws IOException {
|
|
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(SystemConstant.CONNECT_TIME_OUT)// 连接主机服务超时时间
|
|
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(SystemConstant.CONNECT_TIME_OUT)// 连接主机服务超时时间
|
|
.setConnectionRequestTimeout(SystemConstant.CONNECT_TIME_OUT)// 请求超时时间
|
|
.setConnectionRequestTimeout(SystemConstant.CONNECT_TIME_OUT)// 请求超时时间
|
|
.setSocketTimeout(SystemConstant.SOCKET_CONNECT_TIME_OUT)// 数据读取超时时间
|
|
.setSocketTimeout(SystemConstant.SOCKET_CONNECT_TIME_OUT)// 数据读取超时时间
|
|
@@ -66,7 +67,7 @@ public class HttpUtil {
|
|
post.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=utf-8");
|
|
post.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=utf-8");
|
|
post.setHeader("Accept", "application/json");
|
|
post.setHeader("Accept", "application/json");
|
|
|
|
|
|
- String encoderJson = URLEncoder.encode(json, SystemConstant.CHARSET_NAME);
|
|
|
|
|
|
+ String encoderJson = encode ? URLEncoder.encode(json, SystemConstant.CHARSET_NAME) : json;
|
|
StringEntity se = new StringEntity(encoderJson);
|
|
StringEntity se = new StringEntity(encoderJson);
|
|
se.setContentType("text/json");
|
|
se.setContentType("text/json");
|
|
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
|
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|