|
|
@@ -257,6 +257,7 @@ public class HttpUtil {
|
|
|
*/
|
|
|
public static String doPost(String postUrl, String formData) throws Exception {
|
|
|
HttpPost post = null;
|
|
|
+ InputStream in = null;
|
|
|
try {
|
|
|
CloseableHttpClient httpClient = clientSpringFactory.getHttpSyncClient();
|
|
|
post = new HttpPost(postUrl);
|
|
|
@@ -264,12 +265,17 @@ public class HttpUtil {
|
|
|
post.setEntity(postingString);
|
|
|
post.setHeader("Content-type", "application/json");
|
|
|
HttpResponse response = httpClient.execute(post);
|
|
|
- String content = EntityUtils.toString(response.getEntity());
|
|
|
+ HttpEntity entity = response.getEntity();
|
|
|
+ in = entity.getContent();
|
|
|
+ String content = EntityUtils.toString(entity);
|
|
|
return content;
|
|
|
} finally {
|
|
|
if (post != null) {
|
|
|
post.releaseConnection();
|
|
|
}
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -343,13 +349,18 @@ public class HttpUtil {
|
|
|
public static Response sendHttpUriRequest(HttpRequestBase request) throws Exception {
|
|
|
CloseableHttpClient httpClient = clientSpringFactory.getHttpSyncClient();
|
|
|
CloseableHttpResponse response = null;
|
|
|
+ InputStream in = null;
|
|
|
try {
|
|
|
response = httpClient.execute(request);
|
|
|
- return Response.getResponse(response);
|
|
|
+ in = response.getEntity().getContent();
|
|
|
+ return Response.getResponse(response);
|
|
|
} finally {
|
|
|
if (request != null) {
|
|
|
request.releaseConnection();
|
|
|
}
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -365,6 +376,7 @@ public class HttpUtil {
|
|
|
Map<String, Object> params, boolean encode) throws Exception {
|
|
|
CloseableHttpClient httpClient = clientSpringFactory.getHttpSyncClient();
|
|
|
CloseableHttpResponse response = null;
|
|
|
+ InputStream in = null;
|
|
|
try {
|
|
|
if (!encode) {
|
|
|
request.setEntity(new StringEntity(FlexJsonUtils.toJson(params), ContentType.APPLICATION_JSON));
|
|
|
@@ -386,11 +398,15 @@ public class HttpUtil {
|
|
|
request.setEntity(new UrlEncodedFormEntity(nvps));
|
|
|
}
|
|
|
response = httpClient.execute(request);
|
|
|
+ in = response.getEntity().getContent();
|
|
|
return Response.getResponse(response);
|
|
|
} finally {
|
|
|
if (request != null) {
|
|
|
request.releaseConnection();
|
|
|
}
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -539,6 +555,7 @@ public class HttpUtil {
|
|
|
CloseableHttpClient httpClient = clientSpringFactory.getHttpSyncClient();
|
|
|
CloseableHttpResponse response = null;
|
|
|
HttpPost httpPost = null;
|
|
|
+ InputStream in = null;
|
|
|
try {
|
|
|
|
|
|
httpPost = new HttpPost(postUrl);
|
|
|
@@ -555,11 +572,14 @@ public class HttpUtil {
|
|
|
HttpEntity reqEntity = builder.build();
|
|
|
httpPost.setEntity(reqEntity);
|
|
|
response = httpClient.execute(httpPost);
|
|
|
- } finally {
|
|
|
+ in = response.getEntity().getContent();
|
|
|
+ } finally {
|
|
|
if (httpPost != null) {
|
|
|
httpPost.releaseConnection();
|
|
|
}
|
|
|
-
|
|
|
+ if (in != null) {
|
|
|
+ in.close();
|
|
|
+ }
|
|
|
}
|
|
|
return Response.getResponse(response);
|
|
|
}
|