public class ImRequest extends Object
该类为Request会话请求的数据封装类,所有Request会话相关的属性、数据、配置均需要在该类设置
HTTP Request session request data encapsulation class
This class is the data encapsulation class of the Request session request. All the properties, data, and configuration related to the Request session need to be set in this class.
program: Sinlmao Commons Network Utils
description: HTTP Request类
create: 2019-08-01 11:11
| 构造器和说明 |
|---|
ImRequest(String url)
传入URL构造一个ImRequest
Construct an ImRequest with the incoming URL
|
| 限定符和类型 | 方法和说明 |
|---|---|
ImRequest |
addCookie(com.alibaba.fastjson.JSONObject cookies)
添加Cookie,当数据已经存在,则不再添加
Add a Cookie, when the data already exists, it will not be added
|
ImRequest |
addCookie(Map<String,String> cookies)
添加Cookie,当数据已经存在,则不再添加
Add a Cookie, when the data already exists, it will not be added
|
ImRequest |
addCookie(String name,
String value)
添加Cookie,当数据已经存在,则不再添加
Add a Cookie, when the data already exists, it will not be added
|
ImRequest |
addHeader(com.alibaba.fastjson.JSONObject headers)
添加Header,当数据已经存在,则不再添加
Add a Header, when the data already exists, it will not be added
|
ImRequest |
addHeader(Map<String,String> headers)
添加Header,当数据已经存在,则不再添加
Add a Header, when the data already exists, it will not be added
|
ImRequest |
addHeader(String name,
String value)
添加Header,当数据已经存在,则不再添加
Add a Header, when the data already exists, it will not be added
|
ImRequest |
disableProxyServer()
设置禁用通过代理服务器(抓包工具/特殊需要)访问
Setting disabled access via proxy server (capture tool/special needs)
|
ImRequest |
enableProxyServer(int port)
[本地代理] 设置启用通过代理服务器(抓包工具/特殊需要)访问
请注意,如果代理服务器(或抓包工具)配置不当或者无代理服务时可能导致访问异常
[Local Agent] Setting is enabled to access through a proxy server (capture tool/special needs)
Please note that if the proxy server (or the capture tool) is misconfigured or has no proxy service, it may cause an access exception.
|
ImRequest |
enableProxyServer(String host,
int port)
设置启用通过代理服务器(抓包工具/特殊需要)访问
请注意,如果代理服务器(或抓包工具)配置不当或者无代理服务时可能导致访问异常
Set to enable access via a proxy server (capture tool/special needs)
Please note that if the proxy server (or the capture tool) is misconfigured or has no proxy service, it may cause an access exception.
|
int |
getBytesLength()
获取Request会话的内容bytes长度属性
Get the Request bytes length attribute
|
protected ImHttpClientCallback |
getCallback() |
String |
getCharset()
获取Request会话的编码属性
Get the Request Charset attribute
|
ImContentType |
getContentType()
获取Request会话的内容类型(ImContentType)
Get the Request content type (ImContentType)
|
String |
getContentTypeStr()
获取Request会话的内容类型字符表示(String)
如果存在ContentTypeStr属性则返回ContentTypeStr属性
Get the Request string content type (String)
Returns the ContentTypeStr property if there is a ContentTypeStr property
|
String |
getCookieData(String name)
根据Cookie键获得对应值
Get the corresponding value according to the Cookie key
|
Set<String> |
getCookieNames()
获得所有Cookie键
Get all Cookie keys
|
int |
getCookieSize()
获得Cookie数量
Get the count of Cookies
|
Set<String> |
getHeaderNames()
获得所有Header键
Get all Header keys
|
int |
getHeaderSize()
获得Header数量
Get the count of Headers
|
String |
getHeaderValue(String name)
根据Header键获得对应值
Get the corresponding value according to the Header key
|
protected HostnameVerifier |
getHostnameVerifier() |
Object |
getInputData()
获取Request会话的输入数据
Get the Request input data
|
<T> T |
getInputData(Class<T> type)
根据指定的类型获取Request会话的输入数据
比如需要获得一个String类型的属性,则代码为:getInputData(String.class)
According to the specified type get the Request input data
For example, if you need to get a property of type String, the code is: getInputData(String.class)
|
protected KeyManagerFactory |
getKeyManagerFactory() |
protected KeyManager[] |
getKeyManagers() |
ImMethod |
getMethod()
获取Request会话的方法(ImMethod)属性
Get the Request Method(ImMethod) attribute
|
protected String |
getProxyServerHost() |
protected String |
getProxyServerPort() |
Object |
getQueryParams()
获取Request会话的查询参数数据
Get the Request query parameter data
|
<T> T |
getQueryParams(Class<T> type)
根据指定的类型获取Request会话的输入数据
比如需要获得一个String类型的属性,则代码为:getQueryParams(String.class)
According to the specified type get the Request query parameter data
For example, if you need to get a property of type String, the code is: getQueryParams(String.class)
|
protected TrustManager[] |
getTrustManager() |
protected TrustManagerFactory |
getTrustManagerFactory() |
String |
getUrl()
获取Request会话的URL属性
Get the Request URL attribute
|
String |
getUserAgent()
获取Request会话的用户代理(User-Agent)属性
Get the Request User Agent(User-Agent) attribute
|
boolean |
hasContentTypeStr()
获取是否存在ContentTypeStr的定义
Get if there is a definition of ContentTypeStr
|
boolean |
isAllowNonStandard()
获取是否允许非标准使用
Get whether to allow no standard
|
boolean |
isAsync()
获取是否异步执行请求
Get whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
|
boolean |
isAutoServletSessionID()
获取是否自动传递 Java Servlet 的 SessionID,一般是Tomcat需要
Get whether to automatically transfer the SessionID of the Java Servlet, generally required by Tomcat
|
protected boolean |
isEnableProxyServer() |
boolean |
isForceInUrlSendData()
获取是否强制使用URL发送数据
Get whether to force in url send data
|
boolean |
isIgnoreSSLCertVerify()
获取是否忽略SSLCertVerify
Get whether to SSL certVerify
|
boolean |
isKeepAlive()
获取是否需要长连接
Get whether to Keep-Alive
|
boolean |
isRestfulMode()
获取是否为Restful模式
Get whether to restful mode
|
boolean |
isTomcatLowVersionCompatible()
已过时。
1.5.0
|
boolean |
isUrlEncode()
获取是否需要对参数进行URL编码
Get whether you need to URL encode the parameters
|
boolean |
isUseCache()
获取是否使用缓存
Get whether to use cache
|
ImRequest |
setAllowNonStandard(boolean allowNonStandard)
设置是否允许非标准使用
Set whether to allow no standard
|
ImRequest |
setAsync(boolean async)
设置是否异步执行请求
Set whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
|
ImRequest |
setAutoServletSessionID(boolean autoServletSessionID)
设置是否自动传递 Java Servlet 的 SessionID,一般是Tomcat需要
Set whether to automatically transfer the SessionID of the Java Servlet, generally required by Tomcat
|
ImRequest |
setBytesLength(int bytesLength)
设置BytesLength长度
默认为4096
Set Request bytes length
Default is 4096
|
ImRequest |
setCallback(ImHttpClientCallback callback)
设置是否异步执行请求
Set whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
|
ImRequest |
setCharset(ImCharset imCharset)
设置Charset编码
默认为UTF-8
Set the Charset
Default is UTF-8
|
ImRequest |
setCharset(String charset)
设置Charset编码
默认为UTF-8
Set the Charset
Default is UTF-8
|
ImRequest |
setClientCertificate(byte[] bytes,
String password,
String format,
String standard)
设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(byte[] bytes,
String alias,
String password,
String format,
String standard)
设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(File file,
String password,
String format,
String standard)
设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(File file,
String alias,
String password,
String format,
String standard)
设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(InputStream inputStream,
String password,
String format,
String standard)
【完整实现】设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(InputStream inputStream,
String alias,
String password,
String format,
String standard)
设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(KeyManagerFactory keyManagerFactory)
【高级实现】设置客户端需要提供的证书,需要自行实现密钥库管理(KeyManagerFactory)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
[Advanced Implementation] Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setClientCertificate(KeyStore keyStore,
String alias,
String password,
String standard)
【最终实现】设置客户端需要提供的证书,需要提供密码并指定证书格式和密钥算法
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
|
ImRequest |
setContentType(ImContentType contentType)
设置内容类型(ContentType)
默认为application/x-www-form-urlencoded
Set Request content-type
Default is application/x-www-form-urlencoded
|
ImRequest |
setContentType(String contentType)
设置内容类型(ContentType)
Set Request some String content-type
|
ImRequest |
setCookie(com.alibaba.fastjson.JSONObject cookies)
添加Cookie,当数据已经存在,则以最后设置的为准
Set the Cookie.
|
ImRequest |
setCookie(Map<String,String> cookies)
添加Cookie,当数据已经存在,则以最后设置的为准
Set the Cookie.
|
ImRequest |
setCookie(String name,
String value)
添加Cookie,当数据已经存在,则以最后设置的为准
Set the Cookie.
|
ImRequest |
setForceInUrlSendData(boolean forceInUrlSendData)
设置是否强制使用URL发送数据
请注意,强制使用URL发送数据后将不能使用部分数据类型
Set whether to force in url send data
Please note that some data types will not be available after the data is forced to be sent using the URL.
|
ImRequest |
setHeader(com.alibaba.fastjson.JSONObject headers)
设置Header,当数据已经存在,则以最后设置的为准
Set the Header.
|
ImRequest |
setHeader(Map<String,String> headers)
设置Header,当数据已经存在,则以最后设置的为准
Set the Header.
|
ImRequest |
setHeader(String name,
String value)
设置Header,当数据已经存在,则以最后设置的为准
Set the Header.
|
ImRequest |
setHostnameVerifier(HostnameVerifier hostnameVerifier)
设置服务器主机名校验业务接口
注意,一般此类业务应当与服务提供方协商对接
注意,如果设置忽略SSL证书验证则此项设置无效
Set the server host name verification service interface
Note that generally such services should be negotiated and docked with the service provider
Note that if the setting ignores SSL certificate verification, this setting is invalid
|
ImRequest |
setIgnoreSSLCertVerify(boolean ignoreSSLCertVerify)
设置是否忽略SSLCertVerify
Set whether to ignore
|
ImRequest |
setInputData(ImBytesData inputData)
设置ImBytesData类型输入数据
Set ImBytesData/bytes type input data
|
ImRequest |
setInputData(ImFileData inputData)
设置ImFileData类型输入数据
Set ImFileData type input data
|
ImRequest |
setInputData(ImMultipartFormData inputData)
设置ImMultipartFormData类型输入数据
Set ImMultipartFormData type input data
|
ImRequest |
setInputData(com.alibaba.fastjson.JSONObject inputData)
设置JSONObject类型输入数据
Set JSONObject type input data
|
ImRequest |
setInputData(Map<String,String> inputData)
设置Map类型输入数据
Set Map type input data
|
ImRequest |
setInputData(String inputData)
设置String类型输入数据
Set String type input data
|
ImRequest |
setKeepAlive(boolean keepAlive)
设置是否为长连接
Set whether to Keep-Alive
|
ImRequest |
setMethod(ImMethod method)
设置Method方法
默认为GET
Set the Method
Default is GET
|
ImRequest |
setQueryParams(com.alibaba.fastjson.JSONObject queryParams)
设置JSONObject类型查询参数数据
Set JSONObject type query parameter data
|
ImRequest |
setQueryParams(Map<String,String> queryParams)
设置Map类型查询参数数据
Set Map type query parameter data
|
ImRequest |
setQueryParams(String queryParams)
设置String类型查询参数数据
Set String type query parameter data
|
ImRequest |
setRestfulMode(boolean restfulMode)
设置是否为Restful模式
Set whether to restful mode
|
ImRequest |
setTomcatLowVersionCompatible(boolean tomcatLowVersionCompatible)
已过时。
1.5.0
|
ImRequest |
setTrustCertificate(TrustManager[] trustManagers)
【高级实现】设置客户端需要信任服务端的证书信任库,需要自行实现证书信任库对象(TrustManager[])
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
注意,如果设置忽略SSL证书验证则此项设置无效
[Advanced Implementation] Set the client to trust the server's certificate trust store and implement the certificate trust store object (TrustManager[])
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
Note that if the setting ignores SSL certificate verification, this setting is invalid
|
ImRequest |
setTrustCertificate(TrustManagerFactory trustManagerFactory)
【高级实现】设置客户端需要信任服务端的证书信任库,需要自行实现证书信任库管理(TrustManagerFactory)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
注意,如果设置忽略SSL证书验证则此项设置无效
[Advanced Implementation] Set the client to trust the server's certificate trust store, and implement the certificate trust store management (TrustManagerFactory)
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
Note that if the setting ignores SSL certificate verification, this setting is invalid
|
ImRequest |
setUrl(String url)
设置URL
Set the URL
|
ImRequest |
setUrlEncode(boolean urlEncode)
设置是否需要对参数进行URL编码
请注意,如果不在GET方法时或者不在配置强制使用URL发送数据后使用将可能导致数据传输异常
Set whether URL encoding of parameters is required
Please note that if you do not use the GET method or do not use the mandatory URL to send data, it may cause abnormal data transmission.
|
ImRequest |
setUseCache(boolean useCache)
设置是否使用缓存
Set whether to use cache
|
ImRequest |
setUserAgent(String userAgent)
设置用户代理(User-Agent)信息
Set the Use Agent (User-Agent) information
|
public ImRequest(String url)
Construct an ImRequest with the incoming URL
url - URLpublic ImRequest setUrl(String url)
Set the URL
url - URLpublic ImRequest setMethod(ImMethod method)
默认为GET
Set the Method
Default is GET
method - ImMethod方法 public ImRequest setCharset(String charset)
默认为UTF-8
Set the Charset
Default is UTF-8
charset - 编码 public ImRequest setCharset(ImCharset imCharset)
默认为UTF-8
Set the Charset
Default is UTF-8
imCharset - 常见编码枚举 public ImRequest setInputData(String inputData)
Set String type input data
inputData - String类型输入数据 public ImRequest setInputData(Map<String,String> inputData)
Set Map type input data
inputData - Map类型输入数据 public ImRequest setInputData(com.alibaba.fastjson.JSONObject inputData)
Set JSONObject type input data
inputData - JSONObject类型输入数据 public ImRequest setInputData(ImBytesData inputData)
Set ImBytesData/bytes type input data
inputData - ImBytesData类型输入数据 public ImRequest setInputData(ImFileData inputData)
Set ImFileData type input data
inputData - ImFileData类型输入数据 public ImRequest setInputData(ImMultipartFormData inputData)
Set ImMultipartFormData type input data
inputData - ImMultipartFormData类型输入数据 public ImRequest setQueryParams(String queryParams)
Set String type query parameter data
queryParams - String类型查询参数数据 public ImRequest setQueryParams(Map<String,String> queryParams)
Set Map type query parameter data
queryParams - Map类型查询参数数据 public ImRequest setQueryParams(com.alibaba.fastjson.JSONObject queryParams)
Set JSONObject type query parameter data
queryParams - JSONObject类型查询参数数据 public ImRequest setBytesLength(int bytesLength)
默认为4096
Set Request bytes length
Default is 4096
bytesLength - BytesLength长度 public ImRequest setContentType(ImContentType contentType)
默认为application/x-www-form-urlencoded
Set Request content-type
Default is application/x-www-form-urlencoded
contentType - ContentType内容类型 public ImRequest setContentType(String contentType)
Set Request some String content-type
contentType - String内容类型 public ImRequest setIgnoreSSLCertVerify(boolean ignoreSSLCertVerify)
Set whether to ignore
ignoreSSLCertVerify - 是否忽略 public ImRequest setKeepAlive(boolean keepAlive)
Set whether to Keep-Alive
keepAlive - 是否为长连接 public ImRequest setUseCache(boolean useCache)
Set whether to use cache
useCache - 是否使用缓存 public ImRequest setAllowNonStandard(boolean allowNonStandard)
Set whether to allow no standard
allowNonStandard - 是否允许非标准使用 public ImRequest setRestfulMode(boolean restfulMode)
Set whether to restful mode
restfulMode - 是否为Restful模式 public ImRequest setForceInUrlSendData(boolean forceInUrlSendData)
请注意,强制使用URL发送数据后将不能使用部分数据类型
Set whether to force in url send data
Please note that some data types will not be available after the data is forced to be sent using the URL.
forceInUrlSendData - 是否强制使用URL发送数据 public ImRequest setUrlEncode(boolean urlEncode)
请注意,如果不在GET方法时或者不在配置强制使用URL发送数据后使用将可能导致数据传输异常
Set whether URL encoding of parameters is required
Please note that if you do not use the GET method or do not use the mandatory URL to send data, it may cause abnormal data transmission.
urlEncode - 是否需要对参数进行URL编码 public ImRequest enableProxyServer(String host, int port)
请注意,如果代理服务器(或抓包工具)配置不当或者无代理服务时可能导致访问异常
Set to enable access via a proxy server (capture tool/special needs)
Please note that if the proxy server (or the capture tool) is misconfigured or has no proxy service, it may cause an access exception.
host - 代理服务器(或抓包工具)的IP/地址 port - 代理服务器(或抓包工具)的端口 public ImRequest enableProxyServer(int port)
请注意,如果代理服务器(或抓包工具)配置不当或者无代理服务时可能导致访问异常
[Local Agent] Setting is enabled to access through a proxy server (capture tool/special needs)
Please note that if the proxy server (or the capture tool) is misconfigured or has no proxy service, it may cause an access exception.
port - 代理服务器(或抓包工具)的端口 public ImRequest disableProxyServer()
Setting disabled access via proxy server (capture tool/special needs)
@Deprecated public ImRequest setTomcatLowVersionCompatible(boolean tomcatLowVersionCompatible)
Set whether need for low version Tomcat compatibility
tomcatLowVersionCompatible - 是否需要兼容低版本Tomcat public ImRequest setAutoServletSessionID(boolean autoServletSessionID)
Set whether to automatically transfer the SessionID of the Java Servlet, generally required by Tomcat
autoServletSessionID - 是否自动传递 Java Servlet 的 SessionIDpublic ImRequest setUserAgent(String userAgent)
Set the Use Agent (User-Agent) information
userAgent - 用户代理(User-Agent)信息 public ImRequest setAsync(boolean async)
Set whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
async - 是否异步执行请求 ImHttpClientCallbackpublic ImRequest setCallback(ImHttpClientCallback callback)
Set whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
callback - 是否异步执行请求 ImHttpClientCallbackpublic ImRequest addHeader(String name, String value)
Add a Header, when the data already exists, it will not be added
name - Header键 value - Header值 public ImRequest addHeader(Map<String,String> headers)
Add a Header, when the data already exists, it will not be added
headers - Map类型的Header数据 public ImRequest addHeader(com.alibaba.fastjson.JSONObject headers)
Add a Header, when the data already exists, it will not be added
headers - JSONObject类型的Header数据 public ImRequest setHeader(String name, String value)
Set the Header. When the data already exists, the last setting is subject to
name - Header键 value - Header值 public ImRequest setHeader(com.alibaba.fastjson.JSONObject headers)
Set the Header. When the data already exists, the last setting is subject to
headers - JSONObject类型的Header数据 public ImRequest setHeader(Map<String,String> headers)
Set the Header. When the data already exists, the last setting is subject to
headers - Map类型的Header数据 public ImRequest addCookie(String name, String value)
Add a Cookie, when the data already exists, it will not be added
name - Cookie键 value - Cookie值 public ImRequest addCookie(Map<String,String> cookies)
Add a Cookie, when the data already exists, it will not be added
cookies - Map类型的Cookie数据 public ImRequest addCookie(com.alibaba.fastjson.JSONObject cookies)
Add a Cookie, when the data already exists, it will not be added
cookies - JSONObject类型的Cookie数据 public ImRequest setCookie(String name, String value)
Set the Cookie. When the data already exists, the last setting is subject to
name - Cookie键 value - Cookie值 public ImRequest setCookie(Map<String,String> cookies)
Set the Cookie. When the data already exists, the last setting is subject to
cookies - Map类型的Cookie数据 public ImRequest setCookie(com.alibaba.fastjson.JSONObject cookies)
Set the Cookie. When the data already exists, the last setting is subject to
cookies - JSONObject类型的Cookie数据 public ImRequest setClientCertificate(File file, String alias, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
file - 文件对象 alias - 别名,指定后将默认使用此别名的数据向服务端出示 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(File file, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
file - 文件对象 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(byte[] bytes, String alias, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
bytes - 文件二进制数据 alias - 别名,指定后将默认使用此别名的数据向服务端出示 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(byte[] bytes, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
bytes - 文件二进制数据 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(InputStream inputStream, String alias, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
inputStream - 证书文件输入流 alias - 别名,指定后将默认使用此别名的数据向服务端出示 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(InputStream inputStream, String password, String format, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
inputStream - 证书文件输入流 password - 密码(如果有) format - 证书文件格式 standard - 公钥格式标准 public ImRequest setClientCertificate(KeyStore keyStore, String alias, String password, String standard)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
keyStore - 密钥库 alias - 别名,指定后将默认使用此别名的数据向服务端出示 password - 密码(如果有) standard - 公钥格式标准 public ImRequest setClientCertificate(KeyManagerFactory keyManagerFactory)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
[Advanced Implementation] Set the certificate that the client needs to provide, need to provide a password and specify the certificate format and key algorithm
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
keyManagerFactory - 密钥库管理 KeyManagerFactorypublic ImRequest setTrustCertificate(TrustManager[] trustManagers)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
注意,如果设置忽略SSL证书验证则此项设置无效
[Advanced Implementation] Set the client to trust the server's certificate trust store and implement the certificate trust store object (TrustManager[])
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
Note that if the setting ignores SSL certificate verification, this setting is invalid
trustManagers - 证书信任库对象TrustManagerpublic ImRequest setTrustCertificate(TrustManagerFactory trustManagerFactory)
注意,一般此类业务应当与服务提供方协商对接,且以服务提供方实际验证为准
注意,如果设置忽略SSL证书验证则此项设置无效
[Advanced Implementation] Set the client to trust the server's certificate trust store, and implement the certificate trust store management (TrustManagerFactory)
Note that generally such services should be negotiated and docked with the service provider, and the actual verification of the service provider shall prevail
Note that if the setting ignores SSL certificate verification, this setting is invalid
trustManagerFactory - 证书信任库管理 TrustManagerFactorypublic ImRequest setHostnameVerifier(HostnameVerifier hostnameVerifier)
注意,一般此类业务应当与服务提供方协商对接
注意,如果设置忽略SSL证书验证则此项设置无效
Set the server host name verification service interface
Note that generally such services should be negotiated and docked with the service provider
Note that if the setting ignores SSL certificate verification, this setting is invalid
hostnameVerifier - 校验业务接口 HostnameVerifierpublic boolean isIgnoreSSLCertVerify()
Get whether to SSL certVerify
public boolean isKeepAlive()
Get whether to Keep-Alive
public boolean isUseCache()
Get whether to use cache
public boolean isAllowNonStandard()
Get whether to allow no standard
public boolean isRestfulMode()
Get whether to restful mode
public boolean isForceInUrlSendData()
Get whether to force in url send data
public boolean isUrlEncode()
Get whether you need to URL encode the parameters
@Deprecated public boolean isTomcatLowVersionCompatible()
Get the need for low version Tomcat compatibility
public boolean isAutoServletSessionID()
Get whether to automatically transfer the SessionID of the Java Servlet, generally required by Tomcat
public String getUserAgent()
Get the Request User Agent(User-Agent) attribute
public boolean isAsync()
Get whether to execute the request asynchronously
请注意,执行异步请求后,您的代码将不会在过程中同步,返回的ImResponse是一个空值,您需要实现ImHttpCallback获得相应正确的ImResponse
Note that after executing an asynchronous request, your code will not be synchronized in the process, the returned ImResponse is a null value, you need to implement ImHttpCallback to get the correct ImResponse
ImHttpClientCallbackpublic String getUrl()
Get the Request URL attribute
public ImMethod getMethod()
Get the Request Method(ImMethod) attribute
public String getCharset()
Get the Request Charset attribute
public Object getInputData()
Get the Request input data
public <T> T getInputData(Class<T> type)
比如需要获得一个String类型的属性,则代码为:getInputData(String.class)
According to the specified type get the Request input data
For example, if you need to get a property of type String, the code is: getInputData(String.class)
type - 指定的类型 public Object getQueryParams()
Get the Request query parameter data
public <T> T getQueryParams(Class<T> type)
比如需要获得一个String类型的属性,则代码为:getQueryParams(String.class)
According to the specified type get the Request query parameter data
For example, if you need to get a property of type String, the code is: getQueryParams(String.class)
type - 指定的类型 public int getBytesLength()
Get the Request bytes length attribute
public ImContentType getContentType()
Get the Request content type (ImContentType)
public String getContentTypeStr()
如果存在ContentTypeStr属性则返回ContentTypeStr属性
Get the Request string content type (String)
Returns the ContentTypeStr property if there is a ContentTypeStr property
public boolean hasContentTypeStr()
Get if there is a definition of ContentTypeStr
public String getHeaderValue(String name)
Get the corresponding value according to the Header key
name - Header键 public Set<String> getHeaderNames()
Get all Header keys
public int getHeaderSize()
Get the count of Headers
public String getCookieData(String name)
Get the corresponding value according to the Cookie key
name - Cookie键 public Set<String> getCookieNames()
Get all Cookie keys
public int getCookieSize()
Get the count of Cookies
protected boolean isEnableProxyServer()
protected String getProxyServerHost()
protected String getProxyServerPort()
protected ImHttpClientCallback getCallback()
protected KeyManagerFactory getKeyManagerFactory()
protected KeyManager[] getKeyManagers()
protected TrustManagerFactory getTrustManagerFactory()
protected TrustManager[] getTrustManager()
protected HostnameVerifier getHostnameVerifier()
Copyright © 2021. All rights reserved.