类 SimpleHttpClient
java.lang.Object
com.alibaba.csp.sentinel.transport.heartbeat.client.SimpleHttpClient
A very simple HTTP client that only supports GET/POST method and plain text request body. The Content-Type header is always set as
application/x-www-form-urlencoded. All parameters in the request will be encoded using
URLEncoder.encode(String, String).
The result of a HTTP invocation will be wrapped as a SimpleHttpResponse. Content in response body
will be automatically decoded to string with provided charset.
This is a blocking and synchronous client, so an invocation will await the response until timeout exceed.
Note that this is a very NAIVE client, Content-Length must be specified in the
HTTP response header, otherwise, the response body will be dropped. All other body type such as
Transfer-Encoding: chunked, Transfer-Encoding: deflate are not supported.
- 作者:
- leyou, Leo Li
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明get(SimpleHttpRequest request) Execute a GET HTTP request.post(SimpleHttpRequest request) Execute a POST HTTP request.
-
构造器详细资料
-
SimpleHttpClient
public SimpleHttpClient()
-
-
方法详细资料
-
get
Execute a GET HTTP request.- 参数:
request- HTTP request- 返回:
- the response if the request is successful
- 抛出:
IOException- when connection cannot be established or the connection is interrupted
-
post
Execute a POST HTTP request.- 参数:
request- HTTP request- 返回:
- the response if the request is successful
- 抛出:
IOException- when connection cannot be established or the connection is interrupted
-