Package org.miaixz.bus.http
Class Httpx
java.lang.Object
org.miaixz.bus.http.Httpx
发送HTTP请求辅助类
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
ConstructorsConstructorDescriptionHttpx()提供返回实例的静态方法Httpx(int connTimeout, int readTimeout, int writeTimeout) 构建一个自定义配置的 HTTP Client 类Httpx(int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration) 构建一个自定义配置的 HTTP Client 类Httpx(X509TrustManager x509TrustManager) 提供返回实例的静态方法Httpx(DnsX dns, HttpProxy httpProxy, int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration) 构建一个自定义配置的 HTTP Client 类Httpx(DnsX dns, HttpProxy httpProxy, int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration, SSLSocketFactory sslSocketFactory, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) 构建一个自定义配置的 HTTP Client 类 -
Method Summary
Modifier and TypeMethodDescriptionstatic String简单的 GET 请求 使用默认编码 UTF-8static String异步get请求,回调static String简单的 GET 请求 使用自定义编码static String带查询参数 GET 请求 使用默认编码 UTF-8static String带查询参数 GET 请求 使用默认编码 UTF-8static String带查询参数 GET 请求 使用自定义编码static void异步处理的GET请求,自定义请求类型static Stringform 方式 POST 请求static String带查询参数 POST 请求 使用默认编码 UTF-8static String带查询参数 POST 请求 使用自定义编码static Stringstatic Stringform 方式 POST 请求 application/x-www-form-urlencodedstatic String带查询参数 POST 请求 使用默认编码 UTF-8static String带查询参数 POST 请求 使用自定义编码static String表单提交带文件上传static String带查询参数 POST 请求 使用自定义编码static String带查询参数 POST 请求 使用自定义编码static Stringpost(String url, Map<String, String> formMap, Map<String, String> headerMap, String mediaType, String charset) 带查询参数 POST 请求 使用自定义编码static void异步处理的POST请求,自定义请求类型
-
Constructor Details
-
Httpx
public Httpx()提供返回实例的静态方法 -
Httpx
提供返回实例的静态方法- Parameters:
x509TrustManager- 信任管理器
-
Httpx
public Httpx(int connTimeout, int readTimeout, int writeTimeout) 构建一个自定义配置的 HTTP Client 类- Parameters:
connTimeout- 连接readTimeout- 读取writeTimeout- 输出
-
Httpx
public Httpx(int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration) 构建一个自定义配置的 HTTP Client 类- Parameters:
connTimeout- 连接readTimeout- 读取writeTimeout- 输出maxRequests- 最大请求maxRequestsPerHost- 主机最大请求maxIdleConnections- 最大连接keepAliveDuration- 链接时长
-
Httpx
public Httpx(DnsX dns, HttpProxy httpProxy, int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration) 构建一个自定义配置的 HTTP Client 类- Parameters:
dns- DNS 信息httpProxy- 代理信息connTimeout- 连接readTimeout- 读取writeTimeout- 输出maxRequests- 最大请求maxRequestsPerHost- 主机最大请求maxIdleConnections- 最大连接keepAliveDuration- 链接时长
-
Httpx
public Httpx(DnsX dns, HttpProxy httpProxy, int connTimeout, int readTimeout, int writeTimeout, int maxRequests, int maxRequestsPerHost, int maxIdleConnections, int keepAliveDuration, SSLSocketFactory sslSocketFactory, X509TrustManager x509TrustManager, HostnameVerifier hostnameVerifier) 构建一个自定义配置的 HTTP Client 类- Parameters:
dns- DNS 信息httpProxy- 代理信息connTimeout- 连接readTimeout- 读取writeTimeout- 输出maxRequests- 最大请求maxRequestsPerHost- 主机最大请求maxIdleConnections- 最大连接keepAliveDuration- 链接时长sslSocketFactory- 抽象类,扩展自SocketFactory, SSLSocket的工厂x509TrustManager- 证书信任管理器hostnameVerifier- 主机名校验信息
-
-
Method Details
-
get
简单的 GET 请求 使用默认编码 UTF-8- Parameters:
url- URL地址- Returns:
- the
String
-
get
简单的 GET 请求 使用自定义编码- Parameters:
url- URL地址charset- 自定义编码- Returns:
- the
String
-
get
异步get请求,回调- Parameters:
url- URL地址isAsync- 是否异步- Returns:
- the
String
-
get
带查询参数 GET 请求 使用默认编码 UTF-8- Parameters:
url- URL地址formMap- 查询参数- Returns:
- the
String
-
get
异步处理的GET请求,自定义请求类型- Parameters:
url- URL地址callback- 回调信息
-
get
带查询参数 GET 请求 使用默认编码 UTF-8- Parameters:
url- URL地址formMap- 查询参数headerMap- Header参数- Returns:
- the
String
-
get
public static String get(String url, Map<String, String> formMap, Map<String, String> headerMap, String charset) 带查询参数 GET 请求 使用自定义编码- Parameters:
url- URL地址formMap- 查询参数headerMap- Header参数charset- 自定义编码- Returns:
- the
String
-
post
异步处理的POST请求,自定义请求类型- Parameters:
url- URL地址formMap- 查询参数callback- 回调信息
-
post
form 方式 POST 请求- Parameters:
url- URL地址 String- Returns:
- the
String
-
post
form 方式 POST 请求 application/x-www-form-urlencoded- Parameters:
url- URL地址formMap- 查询参数- Returns:
- the
String
-
post
带查询参数 POST 请求 使用默认编码 UTF-8- Parameters:
url- URL地址data- 请求数据mediaType- 类型- Returns:
- the
String
-
post
带查询参数 POST 请求 使用默认编码 UTF-8- Parameters:
url- URL地址formMap- 请求数据mediaType- 类型- Returns:
- the
String
-
post
带查询参数 POST 请求 使用自定义编码- Parameters:
url- URL地址formMap- 请求数据headerMap- 头部数据- Returns:
- the
String
-
post
带查询参数 POST 请求 使用自定义编码- Parameters:
url- URL地址data- 请求数据mediaType- 类型charset- 自定义编码- Returns:
- the
String
-
post
-
post
带查询参数 POST 请求 使用自定义编码- Parameters:
url- URL地址formMap- 请求数据mediaType- 类型charset- 自定义编码- Returns:
- the
String
-
post
public static String post(String url, Map<String, String> formMap, Map<String, String> headerMap, String mediaType) 带查询参数 POST 请求 使用自定义编码- Parameters:
url- URL地址formMap- 请求数据headerMap- 头部数据mediaType- 类型- Returns:
- the
String
-
post
public static String post(String url, Map<String, String> formMap, Map<String, String> headerMap, String mediaType, String charset) 带查询参数 POST 请求 使用自定义编码- Parameters:
url- URL地址formMap- 请求数据headerMap- 头部数据mediaType- 类型charset- 自定义编码- Returns:
- the
String
-
post
表单提交带文件上传- Parameters:
url- 请求地址formMap- 请求参数list- 文件路径- Returns:
- the
String
-