|
|
@@ -5,7 +5,6 @@ import android.util.Log;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.data.StringUtil;
|
|
|
import com.common.hmac.HmacUtils;
|
|
|
-import com.common.preferences.PreferenceUtils;
|
|
|
import com.core.api.wxapi.ApiConfig;
|
|
|
import com.core.api.wxapi.ApiUtils;
|
|
|
import com.core.app.MyApplication;
|
|
|
@@ -37,9 +36,10 @@ import java.util.Set;
|
|
|
|
|
|
@Deprecated
|
|
|
public class HttpClient {
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 发送GET请求
|
|
|
+ *
|
|
|
* @param url
|
|
|
* @param params
|
|
|
* @return
|
|
|
@@ -48,7 +48,8 @@ public class HttpClient {
|
|
|
public String sendGetRequest(String url, Map<String, String> params)
|
|
|
throws Exception {
|
|
|
String result = null;
|
|
|
- DefaultHttpClient httpclient = MyHttpClient.getNewHttpClient(); ;
|
|
|
+ DefaultHttpClient httpclient = MyHttpClient.getNewHttpClient();
|
|
|
+ ;
|
|
|
boolean sign = true;
|
|
|
StringBuilder buf = new StringBuilder(url);
|
|
|
Set<Entry<String, String>> entrys = null;
|
|
|
@@ -94,14 +95,14 @@ public class HttpClient {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public String sendPostRequest(String url, Map<String, String> params)
|
|
|
throws IOException {
|
|
|
- // SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
|
|
|
+ // SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
|
|
|
Log.i("HTTP", "post url=" + url);
|
|
|
String result = null;
|
|
|
HttpResponse response = null;
|
|
|
- DefaultHttpClient httpclient = MyHttpClient.getNewHttpClient(); ;
|
|
|
+ DefaultHttpClient httpclient = MyHttpClient.getNewHttpClient();
|
|
|
+ ;
|
|
|
boolean sign = true;
|
|
|
if (sign) {
|
|
|
url += (url.indexOf("?") == -1 ? "?" : "&") + "_timestamp="
|
|
|
@@ -129,7 +130,7 @@ public class HttpClient {
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (response.getStatusLine().getStatusCode() == 200
|
|
|
|| response.getStatusLine().getStatusCode() == 207) {
|
|
|
String temp = EntityUtils.toString(response.getEntity());
|
|
|
@@ -141,23 +142,23 @@ public class HttpClient {
|
|
|
//b2b cookie save
|
|
|
if (StringUtil.isEmpty(url)) return null;
|
|
|
try {
|
|
|
- if (url.contains(ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().login)){
|
|
|
- String b2bCookie= response.getHeaders("Set-Cookie")[0].getValue()+";"+response.getHeaders("Set-Cookie")[1].getValue();
|
|
|
- LogUtil.d("HttpClient","B2B Cookie:"+b2bCookie);
|
|
|
+ if (url.contains(ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().login)) {
|
|
|
+ String b2bCookie = response.getHeaders("Set-Cookie")[0].getValue() + ";" + response.getHeaders("Set-Cookie")[1].getValue();
|
|
|
+ LogUtil.d("HttpClient", "B2B Cookie:" + b2bCookie);
|
|
|
ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().setCookie(b2bCookie);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- CookieStore cookieStore = httpclient.getCookieStore();
|
|
|
+ CookieStore cookieStore = httpclient.getCookieStore();
|
|
|
for (int i = 0; i < cookieStore.getCookies().size(); i++) {
|
|
|
- if ("218.17.158.219".equals(cookieStore.getCookies().get(i)
|
|
|
+ if ("218.17.158.219".equals(cookieStore.getCookies().get(i)
|
|
|
.getDomain())) {
|
|
|
- PreferenceUtils.putLong(MyApplication.getInstance(), "WebViewCommActivity_time", System.currentTimeMillis());
|
|
|
+// PreferenceUtils.putLong(MyApplication.getInstance(), "WebViewCommActivity_time", System.currentTimeMillis());
|
|
|
MyApplication.cookieERP = cookieStore.getCookies().get(i);
|
|
|
} else {
|
|
|
MyApplication.cookieERP = cookieStore.getCookies().get(i);
|
|
|
- PreferenceUtils.putLong(MyApplication.getInstance(), "WebViewCommActivity_time", System.currentTimeMillis());
|
|
|
+// PreferenceUtils.putLong(MyApplication.getInstance(), "WebViewCommActivity_time", System.currentTimeMillis());
|
|
|
}
|
|
|
}
|
|
|
|