(String path, Map<String, String> params, Map<String, String> headers)
| 86 | } |
| 87 | |
| 88 | public static String put(String path, Map<String, String> params, Map<String, String> headers) throws Exception { |
| 89 | HttpPut method = new HttpPut(path); |
| 90 | RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000) |
| 91 | .setConnectionRequestTimeout(5000).setStaleConnectionCheckEnabled(true).build(); |
| 92 | // 请求的参数信息传递 |
| 93 | List<NameValuePair> paires = new ArrayList<NameValuePair>(); |
| 94 | if (params != null) { |
| 95 | Set<String> keys = params.keySet(); |
| 96 | Iterator<String> iterator = keys.iterator(); |
| 97 | while (iterator.hasNext()) { |
| 98 | String key = (String) iterator.next(); |
| 99 | paires.add(new BasicNameValuePair(key, URLDecoder.decode(params.get(key), "UTF-8"))); |
| 100 | } |
| 101 | } |
| 102 | if (paires.size() > 0) { |
| 103 | HttpEntity entity = new UrlEncodedFormEntity(paires, "utf-8"); |
| 104 | method.setEntity(entity); |
| 105 | } |
| 106 | method.setConfig(requestConfig); |
| 107 | return postMethod(method, params, headers); |
| 108 | } |
| 109 | |
| 110 | public static String post(String path, Map<String, String> params, Map<String, String> headers) throws Exception { |
| 111 | HttpPost method = new HttpPost(path); |
no test coverage detected