public abstract class AbstractHttpUtils extends java.lang.Object implements HttpUtils
限定符和类型 | 字段和说明 |
---|---|
protected HttpStream |
_bodyRaw |
protected java.nio.charset.Charset |
_charset |
protected MultiMap<java.lang.String> |
_cookies |
protected boolean |
_enablePrintln |
protected MultiMap<HttpUploadFile> |
_files |
protected MultiMap<java.lang.String> |
_headers |
protected boolean |
_multipart |
protected MultiMap<java.lang.String> |
_params |
protected Serializer |
_serializer |
protected HttpTimeout |
_timeout |
protected java.lang.String |
_url |
构造器和说明 |
---|
AbstractHttpUtils(java.lang.String url) |
限定符和类型 | 方法和说明 |
---|---|
HttpUtils |
body(byte[] bytes,
java.lang.String contentType)
主体配置
|
HttpUtils |
body(java.io.InputStream raw,
java.lang.String contentType)
主体配置
|
HttpUtils |
body(java.lang.String txt,
java.lang.String contentType)
设置 BODY txt 及内容类型
|
HttpUtils |
bodyOfBean(java.lang.Object obj)
主体配置(由序列化器决定内容类型)
|
HttpUtils |
charset(java.lang.String charset)
编码配置
|
HttpUtils |
cookie(java.lang.String name,
java.lang.String value)
小饼配置(替换)
|
HttpUtils |
cookieAdd(java.lang.String name,
java.lang.String value)
小饼配置(添加)
|
HttpUtils |
cookies(java.lang.Iterable<KeyValues<java.lang.String>> cookies)
小饼配置
|
HttpUtils |
cookies(java.util.Map cookies)
设置请求 cookies
|
HttpUtils |
data(java.lang.Iterable<KeyValues<java.lang.String>> data)
参数配置
|
HttpUtils |
data(java.util.Map data)
设置表单数据
|
HttpUtils |
data(java.lang.String name,
java.lang.String value)
设置表单数据
|
HttpUtils |
data(java.lang.String name,
java.lang.String filename,
java.io.File file)
参数配置
|
HttpUtils |
data(java.lang.String name,
java.lang.String filename,
java.io.InputStream inputStream,
java.lang.String contentType)
参数配置
|
java.lang.String |
delete()
delete 请求并返回 body
|
<T> T |
deleteAs(java.lang.reflect.Type type)
delete 请求并返回 body
|
HttpUtils |
enablePrintln(boolean enable)
启用打印(专为 tester 服务)
|
HttpResponse |
exec(java.lang.String method)
执行请求,返回响应对象(需要自己做关闭处理)
|
java.lang.String |
execAsBody(java.lang.String method)
执行请求并返回响应主体
|
<T> T |
execAsBody(java.lang.String method,
java.lang.reflect.Type type)
执行请求并返回响应主体
|
int |
execAsCode(java.lang.String method)
执行请求并返回代码
|
java.util.concurrent.CompletableFuture<HttpResponse> |
execAsync(java.lang.String method)
异步执行请求
|
protected abstract HttpResponse |
execDo(java.lang.String method,
java.util.concurrent.CompletableFuture<HttpResponse> future) |
java.lang.String |
get()
get 请求并返回 body
|
<T> T |
getAs(java.lang.reflect.Type type)
get 请求并返回 body
|
protected java.lang.String |
getRequestCookieString(MultiMap<java.lang.String> cookies) |
int |
head()
head 请求并返回 code
|
HttpUtils |
header(java.lang.String name,
java.lang.String value)
设置请求头
|
HttpUtils |
headerAdd(java.lang.String name,
java.lang.String value)
添加请求头
|
HttpUtils |
headers(java.lang.Iterable<KeyValues<java.lang.String>> headers)
头配置
|
HttpUtils |
headers(java.util.Map headers)
设置请求头
|
HttpUtils |
multipart(boolean multipart)
是否多部分配置
|
java.lang.String |
options()
options 请求并返回 body
|
java.lang.String |
patch()
patch 请求并返回 body
|
<T> T |
patchAs(java.lang.reflect.Type type)
patch 请求并返回 body
|
java.lang.String |
post()
post 请求并返回 body
|
<T> T |
postAs(java.lang.reflect.Type type)
post 请求并返回 body
|
java.lang.String |
put()
put 请求并返回 body
|
<T> T |
putAs(java.lang.reflect.Type type)
put 请求并返回 body
|
Serializer |
serializer()
获取序列化器
|
HttpUtils |
serializer(Serializer serializer)
配置序列化器
|
HttpUtils |
timeout(int timeoutSeconds)
超时配置
|
HttpUtils |
timeout(int connectTimeoutSeconds,
int writeTimeoutSeconds,
int readTimeoutSeconds)
超时配置
|
protected MultiMap<java.lang.String> |
tryInitCookies() |
protected MultiMap<HttpUploadFile> |
tryInitFiles() |
protected MultiMap<java.lang.String> |
tryInitHeaders() |
protected MultiMap<java.lang.String> |
tryInitParams() |
HttpUtils |
userAgent(java.lang.String ua)
用户代理配置
|
protected boolean _enablePrintln
protected final java.lang.String _url
protected java.nio.charset.Charset _charset
protected MultiMap<java.lang.String> _headers
protected MultiMap<java.lang.String> _cookies
protected MultiMap<java.lang.String> _params
protected MultiMap<HttpUploadFile> _files
protected HttpStream _bodyRaw
protected boolean _multipart
protected HttpTimeout _timeout
protected Serializer _serializer
public HttpUtils serializer(Serializer serializer)
HttpUtils
serializer
在接口中 HttpUtils
public Serializer serializer()
HttpUtils
serializer
在接口中 HttpUtils
public HttpUtils enablePrintln(boolean enable)
HttpUtils
enablePrintln
在接口中 HttpUtils
public HttpUtils timeout(int connectTimeoutSeconds, int writeTimeoutSeconds, int readTimeoutSeconds)
HttpUtils
public HttpUtils headers(java.lang.Iterable<KeyValues<java.lang.String>> headers)
HttpUtils
public HttpUtils header(java.lang.String name, java.lang.String value)
public HttpUtils headerAdd(java.lang.String name, java.lang.String value)
public HttpUtils cookies(java.lang.Iterable<KeyValues<java.lang.String>> cookies)
HttpUtils
public HttpUtils cookie(java.lang.String name, java.lang.String value)
HttpUtils
public HttpUtils cookieAdd(java.lang.String name, java.lang.String value)
HttpUtils
public HttpUtils data(java.lang.Iterable<KeyValues<java.lang.String>> data)
HttpUtils
public HttpUtils data(java.lang.String name, java.lang.String value)
public HttpUtils data(java.lang.String name, java.lang.String filename, java.io.InputStream inputStream, java.lang.String contentType)
HttpUtils
public HttpUtils data(java.lang.String name, java.lang.String filename, java.io.File file)
HttpUtils
public HttpUtils body(java.lang.String txt, java.lang.String contentType)
public HttpUtils bodyOfBean(java.lang.Object obj) throws java.io.IOException
HttpUtils
bodyOfBean
在接口中 HttpUtils
java.io.IOException
public HttpUtils body(java.io.InputStream raw, java.lang.String contentType)
HttpUtils
public java.lang.String get() throws java.io.IOException
HttpUtils
public <T> T getAs(java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
public java.lang.String post() throws java.io.IOException
HttpUtils
public <T> T postAs(java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
public java.lang.String put() throws java.io.IOException
HttpUtils
public <T> T putAs(java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
public java.lang.String patch() throws java.io.IOException
HttpUtils
public <T> T patchAs(java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
public java.lang.String delete() throws java.io.IOException
HttpUtils
public <T> T deleteAs(java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
public java.lang.String options() throws java.io.IOException
HttpUtils
public int head() throws java.io.IOException
HttpUtils
public java.lang.String execAsBody(java.lang.String method) throws java.io.IOException
HttpUtils
execAsBody
在接口中 HttpUtils
java.io.IOException
public <T> T execAsBody(java.lang.String method, java.lang.reflect.Type type) throws java.io.IOException
HttpUtils
execAsBody
在接口中 HttpUtils
java.io.IOException
public int execAsCode(java.lang.String method) throws java.io.IOException
HttpUtils
execAsCode
在接口中 HttpUtils
java.io.IOException
public HttpResponse exec(java.lang.String method) throws java.io.IOException
public java.util.concurrent.CompletableFuture<HttpResponse> execAsync(java.lang.String method)
HttpUtils
protected abstract HttpResponse execDo(java.lang.String method, java.util.concurrent.CompletableFuture<HttpResponse> future) throws java.io.IOException
java.io.IOException
protected java.lang.String getRequestCookieString(MultiMap<java.lang.String> cookies)
protected MultiMap<java.lang.String> tryInitParams()
protected MultiMap<HttpUploadFile> tryInitFiles()
protected MultiMap<java.lang.String> tryInitCookies()
protected MultiMap<java.lang.String> tryInitHeaders()