Skip to content
jinyu edited this page Aug 3, 2016 · 4 revisions

weixin4j本身不依赖http工具包,会根据当前的环境检测确定使用哪个HttpClient,具体顺序是:

NettyHttpClient -> ApacheHttpClient -> OkHttpClient -> SimpleHttpClient(HttpURLConnection)

NettyHttpClient

基于netty实现的http客户端

ApacheHttpClient

基于apache的http工具包,支持commons-httpclient3.xhttpclient4.x

OkHttpClient

基于square的OKHttp工具包,支持OkHttp2OkHttp3

SimpleHttpClient

基于jdk提供的HttpURLConnection实现的http客户端

设置默认的HttpClient

HttpClientFactory.setDefaultFactory(HttpClientFactory);

设置默认的HttpParams

HttpClientFactory.setDefaultParams(HttpParams);