Commit 9a9cd31dfba105c069613d8b5d046c40d9644957
1 parent
f44e255699
Exists in
master
and in
6 other branches
增加设置超时时间
Showing 1 changed file with 4 additions and 6 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java
View file @
9a9cd31
... | ... | @@ -61,7 +61,9 @@ |
61 | 61 | String result = null; |
62 | 62 | try{ |
63 | 63 | httpClient = new SSLClient(); |
64 | + | |
64 | 65 | httpPost = new HttpPost(url); |
66 | + httpPost.setConfig(requestConfig); | |
65 | 67 | //设置参数 |
66 | 68 | List<NameValuePair> list = new ArrayList<NameValuePair>(); |
67 | 69 | Iterator iterator = map.entrySet().iterator(); |
... | ... | @@ -94,7 +96,7 @@ |
94 | 96 | try{ |
95 | 97 | httpClient = new SSLClient(); |
96 | 98 | httpPost = new HttpPost(url); |
97 | - | |
99 | + httpPost.setConfig(requestConfig); | |
98 | 100 | StringEntity stringEntity = new StringEntity(json.toString(),charset); |
99 | 101 | httpPost.setEntity(stringEntity); |
100 | 102 | stringEntity.setContentEncoding("UTF-8"); |
... | ... | @@ -180,7 +182,7 @@ |
180 | 182 | DefaultHttpClient client = new DefaultHttpClient( |
181 | 183 | new PoolingClientConnectionManager()); |
182 | 184 | HttpPost httpPost = new HttpPost(url); |
183 | - | |
185 | + httpPost.setConfig(requestConfig); | |
184 | 186 | httpPost.setHeader("Content-Type", "application/json;charset=UTF-8"); |
185 | 187 | StringEntity se = new StringEntity(JSONstr); |
186 | 188 | se.setContentType(CONTENT_TYPE_TEXT_JSON); |
187 | 189 | |
... | ... | @@ -192,14 +194,10 @@ |
192 | 194 | String STR = EntityUtils.toString(entity, "UTF-8"); |
193 | 195 | JSONObject json2=new JSONObject(); |
194 | 196 | json1=json2.parseObject(STR); |
195 | - | |
196 | - | |
197 | - | |
198 | 197 | }catch (Exception e){ |
199 | 198 | e.printStackTrace(); |
200 | 199 | } |
201 | 200 | return json1; |
202 | 201 | } |
203 | - | |
204 | 202 | } |