对Httpclient的支持

目前TLog对于Httpclient客户端的支持是有侵入性的,对于请求端需要加入拦截器,把日志标签信息记录用过Http Header传递到服务器。

添加拦截器TLogHttpClientInterceptor

代码示例:

String url = "http://127.0.0.1:2111/hi?name=2323";
CloseableHttpClient client = HttpClientBuilder.create()
.addInterceptorFirst(new TLogHttpClientInterceptor())
.build();
HttpGet get = new HttpGet(url);
try {
CloseableHttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
log.info("http response code:{}", response.getStatusLine().getStatusCode());
log.info("http response result:{}",entity == null ? "" : EntityUtils.toString(entity));
} catch (IOException e) {
e.printStackTrace();
}