httpclientutil
httpclientutil copied to clipboard
该项目基于HttpClient-4.4.1封装的一个工具类。提供了更为简单的GET、POST及上传下载等功能。同时支持插件式配置Http-Header(包含自定义header)、配置SSL和Proxy等。
一些建议想要交流
### 超时时间 #### 问题 目前设置超时时间都是HCB.custom().timeout(xxx)的方式进行设置,如果是连接池的话,其设置的是该池中所有Http请求的超时时间。而如果我们想要以更低粒度的方式设置超时时间,也就是说为每个连接池的每个Http请求设置不同的超时时间,目前没有办法设置。 #### 解决方案 1. 添加HttpConfig对象设置超时时间的方法,后面在通过HttpRequestBase对象设置RequestConfig的方式进行设置。 2. 为HttpConfig添加默认的RequestConfig对象,添加设置该对象的方法,这样粒度更大,用户想要自定义时能够更好的扩展。 ### 执行请求,返回结果 #### 问题 在HttpClientUtil执行Http请求的方法中,方法的粒度太小了,比如我想要Http响应头和Http body的话就没有办法同时拿到。 #### 解决方案 1. 添加粒度更大的接口进行处理Http请求,可以需要进行把HttpClientUtil执行请求的方法进行重构以便能够更好的使用。
[](https://infosecwriteups.com/want-to-take-over-the-java-ecosystem-all-you-need-is-a-mitm-1fc329d898fb) --- This is a security fix for a high severity vulnerability in your [Apache Maven](https://maven.apache.org/) `pom.xml` file(s). The build files indicate that this project is resolving dependencies over HTTP...

HttpConfig config = HttpConfig.custom() .headers(headers) .url(iamtokenUrl) .encoding("utf-8") .client(HCB.custom().sslpv(SSLs.SSLProtocolVersion.TLSv1_2).ssl().build()) .json(JSON.toJSONString(map)); String result = HttpClientUtil.post(config); ERROR MESSAGE: com.arronlong.httpclientutil.exception.HttpProcessException: java.net.SocketException: Connection reset at com.arronlong.httpclientutil.HttpClientUtil.execute(HttpClientUtil.java:478) at com.arronlong.httpclientutil.HttpClientUtil.send(HttpClientUtil.java:380) at com.arronlong.httpclientutil.HttpClientUtil.post(HttpClientUtil.java:131) at com.caacitc.tcdm.business.imoc.domain.service.impl.ImocOrderImpl.getIamToken(ImocOrderImpl.java:68)