|
@@ -8,11 +8,13 @@ import java.util.Date;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
+import org.apache.http.Header;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.client.HttpClient;
|
|
|
import org.apache.http.client.config.RequestConfig;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.client.methods.HttpHead;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.client.methods.HttpPut;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
@@ -139,11 +141,17 @@ public class HttpClientUtil {
|
|
|
}
|
|
|
|
|
|
public synchronized String post(String url, String content) throws Exception {
|
|
|
- String result = post(url, content, 300000, null);
|
|
|
+ String result = post(url, content, 300000, null,null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public synchronized String post(String url, String content, Integer timeout, Map<String, String> headerMap) throws Exception {
|
|
|
+ public synchronized String post(String url, String content,HttpServletResponse response) throws Exception {
|
|
|
+ String result = post(url, content, 300000, null,response);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public synchronized String post(String url, String content, Integer timeout, Map<String, String> headerMap,HttpServletResponse response) throws Exception {
|
|
|
if (Constant.http_interval > 0) {
|
|
|
Thread.sleep(Constant.http_interval);
|
|
|
}
|
|
@@ -166,6 +174,11 @@ public class HttpClientUtil {
|
|
|
httpost.setEntity(entity);
|
|
|
entity.setContentType("application/json");
|
|
|
HttpResponse httpResponse = client.execute(httpost);
|
|
|
+ if(url.contains("login"))
|
|
|
+ {
|
|
|
+ Header responseFirstHeader= httpResponse.getFirstHeader("app-token");
|
|
|
+ response.setHeader(responseFirstHeader.getName(),responseFirstHeader.getValue());
|
|
|
+ }
|
|
|
InputStream is = httpResponse.getEntity().getContent();
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
int b = -1;
|