public abstract class AbstractHttpUtils extends Object implements HttpUtils
| Modifier and Type | Field and Description |
|---|---|
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 Proxy |
_proxy |
protected org.noear.solon.core.serialize.Serializer |
_serializer |
protected HttpSslSupplier |
_sslSupplier |
protected HttpTimeout |
_timeout |
protected String |
_url |
| Constructor and Description |
|---|
AbstractHttpUtils(String url) |
| Modifier and Type | Method and Description |
|---|---|
Charset |
charset() |
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,
File file)
参数配置
|
HttpUtils |
data(String name,
String filename,
InputStream inputStream,
String contentType)
参数配置
|
String |
delete()
delete 请求并返回 body
|
<T> T |
deleteAs(Type type)
delete 请求并返回 body
|
HttpUtils |
enablePrintln(boolean enable)
启用打印(专为 tester 服务)
|
HttpResponse |
exec(String method)
执行请求,返回响应对象(需要自己做关闭处理)
|
String |
execAsBody(String method)
执行请求并返回响应主体
|
<T> T |
execAsBody(String method,
Type type)
执行请求并返回响应主体
|
int |
execAsCode(String method)
执行请求并返回代码
|
org.reactivestreams.Publisher<String> |
execAsLineStream(String method)
执行请求并返回文本行流
|
org.reactivestreams.Publisher<ServerSentEvent> |
execAsSseStream(String method)
执行请求并返回服务端推送事件流
|
CompletableFuture<HttpResponse> |
execAsync(String method)
异步执行请求
|
protected abstract HttpResponse |
execDo(String method,
CompletableFuture<HttpResponse> future) |
String |
get()
get 请求并返回 body
|
<T> T |
getAs(Type type)
get 请求并返回 body
|
static String |
getLocationUrl(String refererUrl,
String location)
获取转发的新地址
|
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)
设置请求头
|
protected static boolean |
isRedirected(int responseCode) |
HttpUtils |
multipart(boolean multipart)
是否多部分配置
|
String |
options()
options 请求并返回 body
|
String |
patch()
patch 请求并返回 body
|
<T> T |
patchAs(Type type)
patch 请求并返回 body
|
String |
post()
post 请求并返回 body
|
<T> T |
postAs(Type type)
post 请求并返回 body
|
HttpUtils |
proxy(Proxy proxy)
代理配置
|
String |
put()
put 请求并返回 body
|
<T> T |
putAs(Type type)
put 请求并返回 body
|
org.noear.solon.core.serialize.Serializer |
serializer()
获取序列化器
|
HttpUtils |
serializer(org.noear.solon.core.serialize.Serializer serializer)
配置序列化器
|
HttpUtils |
ssl(HttpSslSupplier sslProvider)
ssl
|
HttpUtils |
timeout(HttpTimeout timeout)
超时配置
|
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, waitaccept, body, body, body, body, body, bodyJson, bodyOfBean, bodyOfJson, bodyOfTxt, bodyRaw, bodyRaw, bodyRaw, bodyRaw, bodyTxt, bodyTxt, contentType, data, execAsEventStream, execAsTextStream, fill, http, http, http, post, postAs, proxy, timeout, timeout, toQueryString, toQueryString, urlEncode, urlEncodeprotected boolean _enablePrintln
protected Proxy _proxy
protected HttpSslSupplier _sslSupplier
protected 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 boolean _multipart
protected HttpTimeout _timeout
protected org.noear.solon.core.serialize.Serializer _serializer
public AbstractHttpUtils(String url)
public HttpUtils serializer(org.noear.solon.core.serialize.Serializer serializer)
HttpUtilsserializer in interface HttpUtilspublic org.noear.solon.core.serialize.Serializer serializer()
HttpUtilsserializer in interface HttpUtilspublic HttpUtils enablePrintln(boolean enable)
HttpUtilsenablePrintln in interface HttpUtilspublic HttpUtils ssl(HttpSslSupplier sslProvider)
HttpUtilspublic HttpUtils timeout(HttpTimeout timeout)
HttpUtilspublic HttpUtils multipart(boolean multipart)
HttpUtilspublic Charset charset()
public 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 cookie(String name, String value)
HttpUtilspublic HttpUtils cookieAdd(String name, String value)
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 data(String name, String filename, File file)
HttpUtilspublic String get() throws HttpException
HttpUtilsget in interface HttpUtilsHttpExceptionpublic <T> T getAs(Type type) throws HttpException
HttpUtilsgetAs in interface HttpUtilsHttpExceptionpublic String post() throws HttpException
HttpUtilspost in interface HttpUtilsHttpExceptionpublic <T> T postAs(Type type) throws HttpException
HttpUtilspostAs in interface HttpUtilsHttpExceptionpublic String put() throws HttpException
HttpUtilsput in interface HttpUtilsHttpExceptionpublic <T> T putAs(Type type) throws HttpException
HttpUtilsputAs in interface HttpUtilsHttpExceptionpublic String patch() throws HttpException
HttpUtilspatch in interface HttpUtilsHttpExceptionpublic <T> T patchAs(Type type) throws HttpException
HttpUtilspatchAs in interface HttpUtilsHttpExceptionpublic String delete() throws HttpException
HttpUtilsdelete in interface HttpUtilsHttpExceptionpublic <T> T deleteAs(Type type) throws HttpException
HttpUtilsdeleteAs in interface HttpUtilsHttpExceptionpublic String options() throws HttpException
HttpUtilsoptions in interface HttpUtilsHttpExceptionpublic int head()
throws HttpException
HttpUtilshead in interface HttpUtilsHttpExceptionpublic String execAsBody(String method) throws HttpException
HttpUtilsexecAsBody in interface HttpUtilsHttpExceptionpublic <T> T execAsBody(String method, Type type) throws HttpException
HttpUtilsexecAsBody in interface HttpUtilsHttpExceptionpublic int execAsCode(String method) throws HttpException
HttpUtilsexecAsCode in interface HttpUtilsHttpExceptionpublic org.reactivestreams.Publisher<String> execAsLineStream(String method)
HttpUtilsexecAsLineStream in interface HttpUtilspublic org.reactivestreams.Publisher<ServerSentEvent> execAsSseStream(String method)
HttpUtilsexecAsSseStream in interface HttpUtilspublic HttpResponse exec(String method) throws HttpException
exec in interface HttpUtilsHttpExceptionpublic 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()
protected static boolean isRedirected(int responseCode)
Copyright © 2025. All rights reserved.