public final class ImHttpClient extends Object
用于发送HTTP请求,所有请求的数据都需要封装在ImRequest中
HTTP Client implementation class
Used to send HTTP requests, all requested data needs to be encapsulated in ImRequest.
program: Sinlmao Commons Network Utils
description: HTTP Client实现类
create: 2019-08-01 11:11
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
get(String url)
快速发起一个GET的请求
Quickly make a GET request
|
static String |
get(String url,
ImCharset charset)
快速发起一个GET的请求
Quickly make a GET request
|
static String |
get(String url,
ImCharset charset,
Map<String,String> params)
快速发起一个GET的请求
Quickly make a GET request
|
static String |
get(String url,
Map<String,String> params)
快速发起一个GET的请求
Quickly make a GET request
|
static String |
post(String url,
ImCharset charset,
Map<String,String> params)
快速发起一个POST的请求
Quickly make a POST request
|
static String |
post(String url,
Map<String,String> params)
快速发起一个POST的请求
Quickly make a POST request
|
static ImResponse |
send(ImRequest imRequest)
发起请求
Send Request
请注意,如果在ImRequest中指示为异步请求,那么此时返回的ImResponse将会是空值,需要在ImRequest中另行实现ImHttpCallback接口才能获得返回值
Note that if the asynchronous request is indicated in the ImRequest, then the ImResponse returned at this time will be null,
and the ImHttpCallback interface needs to be implemented separately in the ImRequest to get the return value.
|
static ImResponse |
send(ImRequest imRequest,
ImSession imSession)
发起一个带会话状态的请求
Send a request with a session state
请注意,如果在ImRequest中指示为异步请求,那么此时返回的ImResponse将会是空值,需要在ImRequest中另行实现ImHttpCallback接口才能获得返回值
Note that if the asynchronous request is indicated in the ImRequest, then the ImResponse returned at this time will be null,
and the ImHttpCallback interface needs to be implemented separately in the ImRequest to get the return value.
|
public static String get(String url) throws IOException, IgnoreSSLException
Quickly make a GET request
url - URLIOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 public static String get(String url, ImCharset charset) throws IOException, IgnoreSSLException
Quickly make a GET request
url - URL charset - 编码类型 IOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 ImCharsetpublic static String get(String url, Map<String,String> params) throws IOException, IgnoreSSLException
Quickly make a GET request
url - URL params - 提交的参数 IOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 Mappublic static String get(String url, ImCharset charset, Map<String,String> params) throws IOException, IgnoreSSLException
Quickly make a GET request
url - URL charset - 编码类型 params - 提交的参数 IOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 ImCharset,
Mappublic static String post(String url, Map<String,String> params) throws IOException, IgnoreSSLException
Quickly make a POST request
url - URL params - 提交的参数 IOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 Mappublic static String post(String url, ImCharset charset, Map<String,String> params) throws IOException, IgnoreSSLException
Quickly make a POST request
url - URL charset - 编码类型 params - 提交的参数 IOException - IO异常 IgnoreSSLException - 忽略SSL相关异常/警告 ImCharset,
Mappublic static ImResponse send(ImRequest imRequest, ImSession imSession) throws SessionException, ContentTypeException, DataTypeException, MethodException, IgnoreSSLException, QueryParamsException, AuthenticationException, IOException
Send a request with a session state
请注意,如果在ImRequest中指示为异步请求,那么此时返回的ImResponse将会是空值,需要在ImRequest中另行实现ImHttpCallback接口才能获得返回值
Note that if the asynchronous request is indicated in the ImRequest, then the ImResponse returned at this time will be null, and the ImHttpCallback interface needs to be implemented separately in the ImRequest to get the return value.
imRequest - ImRequest会话请求数据 imSession - ImSession会话状态数据 SessionException - 会话状态控制相关异常/警告 ContentTypeException - 内容类型(ContentType)使用相关异常/警告 DataTypeException - 数据类型使用相关异常/警告 MethodException - 方法(Method)使用相关异常/警告 IgnoreSSLException - 忽略SSL相关异常/警告 QueryParamsException - 查询参数(QueryParams)相关异常/警告类 AuthenticationException - 身份认证相关异常/警告类 IOException - IO异常 ImRequest,
ImSessionpublic static ImResponse send(ImRequest imRequest) throws ContentTypeException, DataTypeException, MethodException, IgnoreSSLException, QueryParamsException, IOException
Send Request
请注意,如果在ImRequest中指示为异步请求,那么此时返回的ImResponse将会是空值,需要在ImRequest中另行实现ImHttpCallback接口才能获得返回值
Note that if the asynchronous request is indicated in the ImRequest, then the ImResponse returned at this time will be null, and the ImHttpCallback interface needs to be implemented separately in the ImRequest to get the return value.
imRequest - ImRequest会话请求数据 ContentTypeException - 内容类型(ContentType)使用相关异常/警告 DataTypeException - 数据类型使用相关异常/警告 MethodException - 方法(Method)使用相关异常/警告 IgnoreSSLException - 忽略SSL相关异常/警告 QueryParamsException - 查询参数(QueryParams)相关异常/警告类 IOException - IO异常 ImRequestCopyright © 2020. All rights reserved.