| 限定符和类型 | 类和说明 |
|---|---|
static class |
HttpUtilsImpl.StreamBody |
| 构造器和说明 |
|---|
HttpUtilsImpl(String url) |
HttpUtilsImpl(String url,
okhttp3.OkHttpClient client) |
| 限定符和类型 | 方法和说明 |
|---|---|
HttpUtilsImpl |
bodyJson(String txt)
设置 BODY josn
|
HttpUtilsImpl |
bodyRaw(byte[] bytes)
设置 BODY raw
|
HttpUtilsImpl |
bodyRaw(byte[] bytes,
String contentType)
"设置 BODY raw 及内容类型
|
HttpUtilsImpl |
bodyRaw(InputStream raw)
设置 BODY raw stream
|
HttpUtilsImpl |
bodyRaw(InputStream raw,
String contentType)
设置 BODY raw stream 及内容类型
|
HttpUtilsImpl |
bodyTxt(String txt)
设置 BODY txt
|
HttpUtilsImpl |
bodyTxt(String txt,
String contentType)
设置 BODY txt 及内容类型
|
HttpUtilsImpl |
charset(String charset)
设置 charset
|
HttpUtilsImpl |
cookies(Map<String,String> cookies)
设置请求 cookies
|
HttpUtils |
data(Iterable<org.noear.solon.core.util.KeyValues<String>> data)
参数配置
|
HttpUtilsImpl |
data(Map data)
设置表单数据
|
HttpUtilsImpl |
data(String key,
String value)
设置表单数据
|
HttpUtilsImpl |
data(String key,
String filename,
InputStream inputStream,
String contentType)
设置表单文件
|
String |
delete()
发起DELETE请求,返回字符串(RESTAPI.delete 从服务端删除资源)
|
HttpUtils |
enablePrintln(boolean enable)
启用打印(专为 tester 服务)
|
HttpResponse |
exec(String method)
执行请求,返回响应对象
|
String |
execAsBody(String method)
执行请求,返回Body字符串
|
int |
execAsCode(String method)
执行请求,返回状态码
|
void |
execAsync(String method,
HttpCallback callback)
异步执行请求
|
String |
get()
发起GET请求,返回字符串(RESTAPI.select 从服务端获取一或多项资源)
|
void |
getAsync(HttpCallback callback)
get 异步执行请求
|
int |
head()
head 请求并返回 code
|
void |
headAsync(HttpCallback callback)
head 异步执行请求
|
HttpUtilsImpl |
header(String name,
String value)
设置请求头
|
HttpUtilsImpl |
headerAdd(String name,
String value)
添加请求头
|
HttpUtils |
headers(Iterable<org.noear.solon.core.util.KeyValues<String>> headers)
头配置
|
HttpUtilsImpl |
headers(Map<String,String> headers)
设置请求头
|
HttpUtilsImpl |
multipart(boolean multipart)
设置 multipart 标识
|
String |
options()
options 请求并返回 body
|
String |
patch()
发起PATCH请求,返回字符串(RESTAPI.update 客户端提供改变的属性)
|
String |
post()
发起POST请求,返回字符串(RESTAPI.create 在服务端新建一项资源)
|
void |
postAsync(HttpCallback callback)
post 异步执行请求
|
String |
put()
发起PUT请求,返回字符串(RESTAPI.update 客户端提供改变后的完整资源)
|
HttpUtilsImpl |
timeout(int timeoutSeconds)
超时设置
|
HttpUtilsImpl |
timeout(int connectTimeoutSeconds,
int writeTimeoutSeconds,
int readTimeoutSeconds)
超时设置
|
static String |
toQueryString(Map<?,?> map)
map 转为 queryString
|
static String |
urlEncode(String s)
url 编码
|
HttpUtilsImpl |
userAgent(String ua)
设置 UA
|
public HttpUtilsImpl(String url)
public HttpUtilsImpl(String url, okhttp3.OkHttpClient client)
public HttpUtils enablePrintln(boolean enable)
HttpUtilsenablePrintln 在接口中 HttpUtilspublic HttpUtilsImpl timeout(int timeoutSeconds)
public HttpUtilsImpl timeout(int connectTimeoutSeconds, int writeTimeoutSeconds, int readTimeoutSeconds)
public HttpUtilsImpl multipart(boolean multipart)
public HttpUtilsImpl userAgent(String ua)
public HttpUtilsImpl charset(String charset)
public HttpUtils headers(Iterable<org.noear.solon.core.util.KeyValues<String>> headers)
HttpUtilspublic HttpUtilsImpl header(String name, String value)
public HttpUtilsImpl headerAdd(String name, String value)
public HttpUtilsImpl data(Map data)
public HttpUtils data(Iterable<org.noear.solon.core.util.KeyValues<String>> data)
HttpUtilspublic HttpUtilsImpl data(String key, String value)
public HttpUtilsImpl data(String key, String filename, InputStream inputStream, String contentType)
public HttpUtilsImpl bodyTxt(String txt)
public HttpUtilsImpl bodyTxt(String txt, String contentType)
public HttpUtilsImpl bodyJson(String txt)
public HttpUtilsImpl bodyRaw(byte[] bytes)
public HttpUtilsImpl bodyRaw(byte[] bytes, String contentType)
public HttpUtilsImpl bodyRaw(InputStream raw)
public HttpUtilsImpl bodyRaw(InputStream raw, String contentType)
public HttpUtilsImpl cookies(Map<String,String> cookies)
public HttpResponse exec(String method) throws IOException
exec 在接口中 HttpUtilsIOExceptionpublic String execAsBody(String method) throws IOException
execAsBody 在接口中 HttpUtilsIOExceptionpublic int execAsCode(String method) throws IOException
execAsCode 在接口中 HttpUtilsIOExceptionpublic String get() throws IOException
get 在接口中 HttpUtilsIOExceptionpublic String post() throws IOException
post 在接口中 HttpUtilsIOExceptionpublic void postAsync(HttpCallback callback)
HttpUtilspublic void getAsync(HttpCallback callback)
HttpUtilspublic void headAsync(HttpCallback callback)
HttpUtilspublic void execAsync(String method, HttpCallback callback)
HttpUtilspublic String put() throws IOException
put 在接口中 HttpUtilsIOExceptionpublic String patch() throws IOException
patch 在接口中 HttpUtilsIOExceptionpublic String delete() throws IOException
delete 在接口中 HttpUtilsIOExceptionpublic String options() throws IOException
HttpUtilsoptions 在接口中 HttpUtilsIOExceptionpublic int head()
throws IOException
HttpUtilshead 在接口中 HttpUtilsIOExceptionpublic static String toQueryString(Map<?,?> map) throws UnsupportedEncodingException
HttpUtilstoQueryString 在接口中 HttpUtilsUnsupportedEncodingExceptionCopyright © 2024. All rights reserved.