Package | Description |
---|---|
org.dromara.hutool.http |
Hutool-http针对JDK的HttpUrlConnection做一层封装,简化了HTTPS请求、文件上传、Cookie记忆等操作,使Http请求变得无比简单。
|
org.dromara.hutool.http.client |
HTTP请求客户端封装,请求过程如下:
Server
^ |
| v
Request Response
^ |
| v
ClientEngine
|
org.dromara.hutool.http.client.engine |
Http客户端引擎实现
|
org.dromara.hutool.http.client.engine.httpclient4 |
Apache HttpClient 4.x实现
文档见:https://hc.apache.org/httpcomponents-client-4.5.x/index.html |
org.dromara.hutool.http.client.engine.httpclient5 |
Apache HttpClient 5.1.x实现
文档见:https://hc.apache.org/httpcomponents-client-5.1.x/index.html |
org.dromara.hutool.http.client.engine.jdk |
基于JDK的HttpUrlConnection封装的HTTP客户端
|
org.dromara.hutool.http.client.engine.okhttp |
OKHttp3封装
文档见:https://square.github.io/okhttp/ |
Modifier and Type | Method and Description |
---|---|
static ClientEngine |
HttpUtil.createClient(String engineName)
创建客户端引擎
|
Modifier and Type | Method and Description |
---|---|
Response |
Request.send(ClientEngine engine)
发送请求
|
HttpDownloader |
HttpDownloader.setEngine(ClientEngine engine)
设置引擎,用于自定义引擎
|
Modifier and Type | Class and Description |
---|---|
class |
AbstractClientEngine
客户端引擎抽象类,用于保存配置和定义初始化,并提供:
AbstractClientEngine.reset() 用于重置客户端
AbstractClientEngine.initEngine() 初始化客户端
|
Modifier and Type | Method and Description |
---|---|
static ClientEngine |
ClientEngineFactory.createEngine()
根据用户引入的HTTP客户端引擎jar,自动创建对应的HTTP客户端引擎对象
推荐创建的引擎单例使用,此方法每次调用会返回新的引擎 |
static ClientEngine |
ClientEngineFactory.createEngine(ClientConfig config)
根据用户引入的HTTP客户端引擎jar,自动创建对应的HTTP客户端引擎对象
推荐创建的引擎单例使用,此方法每次调用会返回新的引擎 对不同引擎个性化配置,使用对应的 ClientConfig 子类:
HttpClient4和HttpClient5使用ApacheHttpClientConfig
OkHttp使用OkHttpClientConfig
如果混用这些配置,则个性配置不生效 |
static ClientEngine |
ClientEngineFactory.createEngine(String engineName)
创建自定义引擎
|
static ClientEngine |
ClientEngineFactory.getEngine()
获得单例的ClientEngine
|
ClientEngine |
ClientEngine.init(ClientConfig config)
设置客户端引擎参数,如超时、代理等信息
对不同引擎个性化配置,使用对应的
ClientConfig 子类:
HttpClient4和HttpClient5使用ApacheHttpClientConfig
OkHttp使用OkHttpClientConfig
如果混用这些配置,则个性配置不生效 |
ClientEngine |
AbstractClientEngine.init(ClientConfig config) |
Modifier and Type | Class and Description |
---|---|
class |
HttpClient4Engine
Apache HttpClient5的HTTP请求引擎
|
Modifier and Type | Class and Description |
---|---|
class |
HttpClient5Engine
Apache HttpClient5的HTTP请求引擎
|
Modifier and Type | Class and Description |
---|---|
class |
JdkClientEngine
基于JDK的UrlConnection的Http客户端引擎实现
|
Modifier and Type | Class and Description |
---|---|
class |
OkHttpEngine
OkHttp3客户端引擎封装
|
Copyright © 2025. All rights reserved.