String url = "http://www.qq.com";
String reqBody = "";
final HttpPatch httpUriRequest = new HttpPatch(url);
httpUriRequest.setHeader("cookie", "token=" + token);
httpUriRequest.setHeader("content-type", "application/json;charset=UTF-8");
httpUriRequest.setEntity(new StringEntity(reqBody));
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(120_000).setConnectTimeout(120_000).build();
httpUriRequest.setConfig(requestConfig);
HttpResponse response = httpClient.execute(httpUriRequest);
HttpEntity entity = response.getEntity();
if (entity != null) {
final String body = EntityUtils.toString(entity, CharEncoding.UTF_8);
log.info("depApp,respBody={}", body);
return body;
} else {
log.info("depApp,respBody empty");
return "entity empty";
}
httpclient发起patch请求
最新推荐文章于 2024-05-25 22:35:47 发布