/**
* 根据url获取输入流(POST),https,利用HttpClient
*
* @param url
* @param content
* @param accessToken
* @return
* @throws IOException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static InputStream getHttpsInputStreamByHttpClient(String url, String content)
throws IOException, NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
String action = url;
CloseableHttpClient httpclient = HttpClients.custom().build();
HttpPost httpPost=new HttpPost(url);
StringEntity stringEntity=new StringEntity(content.toString(),"utf-8"); //这里设置发送内容的编码格式
httpPost.setEntity(stringEntity);
CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity();
return entity.getContent();
}
HttpClient设置发送内容的编码格式
最新推荐文章于 2024-07-26 02:57:51 发布