java 请求头Header[] headers对象使用
String post(String url, Map<String, String> params, Header[] headers) Exception { CloseableHttpClient httpclient = HttpClientManager.(()); HttpPost httpPost = HttpPost(url); (headers != ) { httpPost.setHeaders(headers); } (httpPost); List<NameValuePair> nvps = ArrayList<NameValuePair>(); Set<String> keys = params.keySet(); (String key : keys) { nvps.add(BasicNameValuePair(key, params.get(key))); } httpPost.setEntity(UrlEncodedFormEntity(nvps, StandardCharsets.)); CloseableHttpResponse response = httpclient.execute(httpPost); { HttpEntity entity = response.getEntity(); EntityUtils.(entity); } { response.close(); } }