@Preview(value="3.0")
public interface HttpUtils
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
log |
| Modifier and Type | Method and Description |
|---|---|
default HttpUtils |
accept(String accept)
Accept 头配置
|
default HttpUtils |
body(byte[] bytes)
主体配置
|
HttpUtils |
body(byte[] bytes,
String contentType)
主体配置
|
default HttpUtils |
body(InputStream raw)
主体配置
|
HttpUtils |
body(InputStream raw,
String contentType)
主体配置
|
HttpUtils |
body(String txt,
String contentType)
主体配置
|
default HttpUtils |
bodyJson(String txt)
Deprecated.
|
HttpUtils |
bodyOfBean(Object obj)
主体配置(由序列化器决定内容类型)
|
default HttpUtils |
bodyOfJson(String txt)
主体配置
|
default HttpUtils |
bodyOfTxt(String txt)
主体配置
|
default HttpUtils |
bodyRaw(byte[] bytes)
Deprecated.
3.0
body(byte[]) |
default HttpUtils |
bodyRaw(byte[] bytes,
String contentType)
Deprecated.
|
default HttpUtils |
bodyRaw(InputStream raw)
Deprecated.
|
default HttpUtils |
bodyRaw(InputStream raw,
String contentType)
Deprecated.
|
default HttpUtils |
bodyTxt(String txt)
Deprecated.
|
default HttpUtils |
bodyTxt(String txt,
String contentType)
Deprecated.
|
HttpUtils |
charset(String charset)
编码配置
|
default HttpUtils |
contentType(String contentType)
Content-Type 头配置
|
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)
小饼配置
|
HttpUtils |
data(Iterable<org.noear.solon.core.util.KeyValues<String>> data)
参数配置
|
HttpUtils |
data(Map data)
参数配置
|
default HttpUtils |
data(String name,
File file)
参数配置
|
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)
执行请求并返回代码
|
default org.reactivestreams.Publisher<ServerSentEvent> |
execAsEventStream(String method)
Deprecated.
|
org.reactivestreams.Publisher<String> |
execAsLineStream(String method)
执行请求并返回文本行流
|
org.reactivestreams.Publisher<ServerSentEvent> |
execAsSseStream(String method)
执行请求并返回服务端推送事件流
|
default org.reactivestreams.Publisher<String> |
execAsTextStream(String method)
Deprecated.
|
CompletableFuture<HttpResponse> |
execAsync(String method)
异步执行请求
|
default HttpUtils |
fill(Consumer<HttpUtils> consumer)
填充自己
|
String |
get()
get 请求并返回 body
|
<T> T |
getAs(Type type)
get 请求并返回 body
|
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)
头配置
|
static HttpUtils |
http(String url)
创建
|
static HttpUtils |
http(String service,
String path)
创建
|
static HttpUtils |
http(String group,
String service,
String path)
创建
|
HttpUtils |
multipart(boolean multipart)
是否多部分配置
|
String |
options()
options 请求并返回 body
|
String |
patch()
patch 请求并返回 body
|
<T> T |
patchAs(Type type)
patch 请求并返回 body
|
String |
post()
post 请求并返回 body
|
default String |
post(boolean useMultipart)
post 请求并返回 body
|
<T> T |
postAs(Type type)
post 请求并返回 body
|
default <T> T |
postAs(Type type,
boolean useMultipart)
post 请求并返回 body
|
HttpUtils |
proxy(Proxy proxy)
代理配置
|
default HttpUtils |
proxy(String host,
int port)
代理配置
|
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)
超时配置
|
default HttpUtils |
timeout(int timeoutSeconds)
超时配置
|
default HttpUtils |
timeout(int connectTimeoutSeconds,
int writeTimeoutSeconds,
int readTimeoutSeconds)
超时配置
|
static CharSequence |
toQueryString(Map<?,?> map)
map 转为 queryString
|
static CharSequence |
toQueryString(Map<?,?> map,
String charset)
map 转为 queryString
|
static String |
urlEncode(String s)
url 编码
|
static String |
urlEncode(String s,
String charset)
url 编码
|
HttpUtils |
userAgent(String ua)
用户代理配置
|
HttpUtils serializer(org.noear.solon.core.serialize.Serializer serializer)
org.noear.solon.core.serialize.Serializer serializer()
HttpUtils enablePrintln(boolean enable)
HttpUtils ssl(HttpSslSupplier sslProvider)
default HttpUtils timeout(int timeoutSeconds)
default HttpUtils timeout(int connectTimeoutSeconds, int writeTimeoutSeconds, int readTimeoutSeconds)
HttpUtils timeout(HttpTimeout timeout)
HttpUtils multipart(boolean multipart)
HttpUtils data(String name, String filename, InputStream inputStream, String contentType)
HttpUtils bodyOfBean(Object obj) throws HttpException
HttpExceptiondefault HttpUtils body(byte[] bytes)
HttpUtils body(InputStream raw, String contentType)
default HttpUtils body(InputStream raw)
String get() throws HttpException
HttpException<T> T getAs(Type type) throws HttpException
HttpExceptionString post() throws HttpException
HttpException<T> T postAs(Type type) throws HttpException
HttpExceptiondefault String post(boolean useMultipart) throws HttpException
HttpExceptiondefault <T> T postAs(Type type, boolean useMultipart) throws HttpException
HttpExceptionString put() throws HttpException
HttpException<T> T putAs(Type type) throws HttpException
HttpExceptionString patch() throws HttpException
HttpException<T> T patchAs(Type type) throws HttpException
HttpExceptionString delete() throws HttpException
HttpException<T> T deleteAs(Type type) throws HttpException
HttpExceptionString options() throws HttpException
HttpExceptionint head() throws HttpException
HttpExceptionString execAsBody(String method) throws HttpException
HttpException<T> T execAsBody(String method, Type type) throws HttpException
HttpExceptionint execAsCode(String method) throws HttpException
HttpException@Deprecated default org.reactivestreams.Publisher<String> execAsTextStream(String method)
execAsLineStream(String)org.reactivestreams.Publisher<ServerSentEvent> execAsSseStream(String method)
@Deprecated default org.reactivestreams.Publisher<ServerSentEvent> execAsEventStream(String method)
execAsSseStream(String)HttpResponse exec(String method) throws HttpException
HttpExceptionCompletableFuture<HttpResponse> execAsync(String method)
@Deprecated default HttpUtils bodyTxt(String txt, String contentType)
body(String, String)@Deprecated default HttpUtils bodyTxt(String txt)
bodyOfTxt(String)@Deprecated default HttpUtils bodyJson(String txt)
bodyOfJson(String)@Deprecated default HttpUtils bodyRaw(byte[] bytes, String contentType)
body(byte[], String)@Deprecated default HttpUtils bodyRaw(byte[] bytes)
body(byte[])@Deprecated default HttpUtils bodyRaw(InputStream raw)
body(InputStream)@Deprecated default HttpUtils bodyRaw(InputStream raw, String contentType)
body(byte[], String)static String urlEncode(String s) throws IOException
IOExceptionstatic String urlEncode(String s, String charset) throws UnsupportedEncodingException
UnsupportedEncodingExceptionstatic CharSequence toQueryString(Map<?,?> map) throws IOException
IOExceptionstatic CharSequence toQueryString(Map<?,?> map, String charset) throws IOException
IOExceptionCopyright © 2025. All rights reserved.