|
@@ -7,7 +7,9 @@ import javax.net.ssl.SSLContext;
|
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
|
import javax.net.ssl.TrustManager;
|
|
|
import javax.net.ssl.X509TrustManager;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.security.cert.X509Certificate;
|
|
@@ -16,7 +18,6 @@ import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
-import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -213,7 +214,7 @@ public class OkHttpUtils {
|
|
|
* false等于普通的表单提交
|
|
|
* @return
|
|
|
*/
|
|
|
- public OkHttpUtils post(boolean isJsonPost,String paramMap) {
|
|
|
+ public OkHttpUtils post(boolean isJsonPost,String paramMap, HttpServletRequest httpServletRequest) {
|
|
|
RequestBody requestBody;
|
|
|
if (isJsonPost) {
|
|
|
String json = "";
|
|
@@ -230,7 +231,14 @@ public class OkHttpUtils {
|
|
|
// }
|
|
|
// requestBody = formBody.build();
|
|
|
}
|
|
|
- request = new Request.Builder().post(requestBody).url(url);
|
|
|
+ Request.Builder request2 = new Request.Builder();
|
|
|
+ if (httpServletRequest != null) {
|
|
|
+ String authorization = httpServletRequest.getHeader("Authorization");
|
|
|
+ if (authorization != null) {
|
|
|
+ request2.header("Authorization",authorization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ request = request2.post(requestBody).url(url);
|
|
|
return this;
|
|
|
}
|
|
|
|