public abstract class AbstractHttpUtils extends Object implements HttpUtils
| 限定符和类型 | 字段和说明 |
|---|---|
protected HttpStream |
_bodyRaw |
protected Charset |
_charset |
protected org.noear.solon.core.util.MultiMap<String> |
_cookies |
protected boolean |
_enablePrintln |
protected org.noear.solon.core.util.MultiMap<HttpUploadFile> |
_files |
protected org.noear.solon.core.util.MultiMap<String> |
_headers |
protected boolean |
_multipart |
protected org.noear.solon.core.util.MultiMap<String> |
_params |
protected HttpTimeout |
_timeout |
protected String |
_url |
| 构造器和说明 |
|---|
AbstractHttpUtils(String url) |
| 限定符和类型 | 方法和说明 |
|---|---|
HttpUtils |
bodyJson(String txt)
主体配置
|
HttpUtils |
bodyRaw(byte[] bytes)
主体配置
|
HttpUtils |
bodyRaw(byte[] bytes,
String contentType)
主体配置
|
HttpUtils |
bodyRaw(InputStream raw)
主体配置
|
HttpUtils |
bodyRaw(InputStream raw,
String contentType)
主体配置
|
HttpUtils |
bodyTxt(String txt)
设置 BODY txt
|
HttpUtils |
bodyTxt(String txt,
String contentType)
设置 BODY txt 及内容类型
|
HttpUtils |
charset(String charset)
编码配置
|
HttpUtils |
cookie(String name,
String value)
小饼配置(替换)
|
HttpUtils |
cookieAdd(String name,
String value)
小饼配置(添加)
|
HttpUtils |
cookies(Iterable<org.noear.solon.core.util.KeyValues<String>> cookies)
小饼配置
|
HttpUtils |
cookies(Map cookies)
设置请求 cookies
|
HttpUtils |
data(Iterable<org.noear.solon.core.util.KeyValues<String>> data)
参数配置
|
HttpUtils |
data(Map data)
设置表单数据
|
HttpUtils |
data(String name,
String value)
设置表单数据
|
HttpUtils |
data(String name,
String filename,
InputStream inputStream,
String contentType)
参数配置
|
String |
delete()
delete 请求并返回 body
|
HttpUtils |
enablePrintln(boolean enable)
启用打印(专为 tester 服务)
|
HttpResponse |
exec(String method)
执行请求,返回响应对象(需要自己做关闭处理)
|
String |
execAsBody(String method)
执行请求并返回响应主体
|
int |
execAsCode(String method)
执行请求并返回代码
|
CompletableFuture<HttpResponse> |
execAsync(String method)
异步执行请求
|
protected abstract HttpResponse |
execDo(String method,
CompletableFuture<HttpResponse> future) |
String |
get()
get 请求并返回 body
|
protected String |
getRequestCookieString(org.noear.solon.core.util.MultiMap<String> cookies) |
int |
head()
head 请求并返回 code
|
HttpUtils |
header(String name,
String value)
设置请求头
|
HttpUtils |
headerAdd(String name,
String value)
添加请求头
|
HttpUtils |
headers(Iterable<org.noear.solon.core.util.KeyValues<String>> headers)
头配置
|
HttpUtils |
headers(Map headers)
设置请求头
|
HttpUtils |
multipart(boolean multipart)
是否多部分配置
|
String |
options()
options 请求并返回 body
|
String |
patch()
patch 请求并返回 body
|
String |
post()
post 请求并返回 body
|
String |
put()
put 请求并返回 body
|
HttpUtils |
timeout(int timeoutSeconds)
超时配置
|
HttpUtils |
timeout(int connectTimeoutSeconds,
int writeTimeoutSeconds,
int readTimeoutSeconds)
超时配置
|
protected org.noear.solon.core.util.MultiMap<String> |
tryInitCookies() |
protected org.noear.solon.core.util.MultiMap<HttpUploadFile> |
tryInitFiles() |
protected org.noear.solon.core.util.MultiMap<String> |
tryInitHeaders() |
protected org.noear.solon.core.util.MultiMap<String> |
tryInitParams() |
HttpUtils |
userAgent(String ua)
用户代理配置
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithttp, http, http, toQueryString, toQueryString, urlEncode, urlEncodeprotected boolean _enablePrintln
protected final String _url
protected Charset _charset
protected org.noear.solon.core.util.MultiMap<String> _headers
protected org.noear.solon.core.util.MultiMap<String> _cookies
protected org.noear.solon.core.util.MultiMap<String> _params
protected org.noear.solon.core.util.MultiMap<HttpUploadFile> _files
protected HttpStream _bodyRaw
protected boolean _multipart
protected HttpTimeout _timeout
public AbstractHttpUtils(String url)
public HttpUtils enablePrintln(boolean enable)
HttpUtilsenablePrintln 在接口中 HttpUtilspublic HttpUtils timeout(int connectTimeoutSeconds, int writeTimeoutSeconds, int readTimeoutSeconds)
HttpUtilspublic HttpUtils headers(Iterable<org.noear.solon.core.util.KeyValues<String>> headers)
HttpUtilspublic HttpUtils cookies(Iterable<org.noear.solon.core.util.KeyValues<String>> cookies)
HttpUtilspublic HttpUtils data(Iterable<org.noear.solon.core.util.KeyValues<String>> data)
HttpUtilspublic HttpUtils data(String name, String filename, InputStream inputStream, String contentType)
HttpUtilspublic HttpUtils bodyRaw(InputStream raw)
HttpUtilspublic HttpUtils bodyRaw(InputStream raw, String contentType)
HttpUtilspublic String get() throws IOException
HttpUtilsget 在接口中 HttpUtilsIOExceptionpublic String post() throws IOException
HttpUtilspost 在接口中 HttpUtilsIOExceptionpublic String put() throws IOException
HttpUtilsput 在接口中 HttpUtilsIOExceptionpublic String patch() throws IOException
HttpUtilspatch 在接口中 HttpUtilsIOExceptionpublic String delete() throws IOException
HttpUtilsdelete 在接口中 HttpUtilsIOExceptionpublic String options() throws IOException
HttpUtilsoptions 在接口中 HttpUtilsIOExceptionpublic int head()
throws IOException
HttpUtilshead 在接口中 HttpUtilsIOExceptionpublic String execAsBody(String method) throws IOException
HttpUtilsexecAsBody 在接口中 HttpUtilsIOExceptionpublic int execAsCode(String method) throws IOException
HttpUtilsexecAsCode 在接口中 HttpUtilsIOExceptionpublic HttpResponse exec(String method) throws IOException
exec 在接口中 HttpUtilsIOExceptionpublic CompletableFuture<HttpResponse> execAsync(String method)
HttpUtilsprotected abstract HttpResponse execDo(String method, CompletableFuture<HttpResponse> future) throws IOException
IOExceptionprotected String getRequestCookieString(org.noear.solon.core.util.MultiMap<String> cookies)
protected org.noear.solon.core.util.MultiMap<String> tryInitParams()
protected org.noear.solon.core.util.MultiMap<HttpUploadFile> tryInitFiles()
protected org.noear.solon.core.util.MultiMap<String> tryInitCookies()
protected org.noear.solon.core.util.MultiMap<String> tryInitHeaders()
Copyright © 2024. All rights reserved.