public interface Request extends Cloneable
| 限定符和类型 | 接口和说明 |
|---|---|
static class |
Request.ContentType |
static class |
Request.Method |
static class |
Request.UserAgent |
| 限定符和类型 | 方法和说明 |
|---|---|
Request |
acceptEncoding(boolean acceptEncoding)
是否允许服务端压缩
|
Request |
addHeader(String name,
String value)
设置头部字段信息
|
Request |
ajax()
设置ajax请求头部
|
Request |
basicAuth(String username,
String password)
设置Basic Auth请求头部
|
Request |
boundary(String boundary)
指定boundary
|
Request |
charset(String charset)
指定编码格式
|
Request |
clone()
clone方法
|
Request |
connectTimeout(int connectTimeoutMillis)
设置连接超时时间(毫秒)
|
Request |
contentType(Request.ContentType contentType)
指定Content-Type
|
Request |
contentType(String contentType)
指定Content-Type
|
Request |
cookie(HttpCookie httpCookie)
设置Cookie头部
|
Request |
cookie(List<HttpCookie> httpCookieList)
设置Cookie头部列表
|
Request |
cookie(String cookie)
设置Cookie头部
|
Request |
cookie(String name,
String value)
设置Cookie头部
|
Request |
data(Map<String,String> dataMap)
设置表单请求参数
|
Request |
data(String key,
Path file)
设置表单请求参数
|
Request |
data(String key,
String value)
设置表单请求参数
|
void |
enqueue(ResponseListener responseListener)
异步执行请求
|
Response |
execute()
执行请求
|
Request |
followRedirects(boolean followRedirects)
是否自动重定向
|
Request |
headers(Map<String,List<String>> headerMap)
设置头部字段信息
|
Request |
ignoreHttpErrors(boolean ignoreHttpErrors)
是否忽略http错误(4xx和5xx响应码)
|
Request |
maxFollowRedirectTimes(int maxFollowRedirectTimes)
指定最大重定向次数
|
Request |
method(Request.Method method)
设置请求方法
|
Request |
method(String method)
设置请求方法
|
Request |
parameter(String key,
String value)
设置路径请求参数
|
Request |
proxy(Proxy proxy)
设置代理
|
Request |
proxy(String host,
int port)
设置代理
|
Request |
ranges(long start,
long end)
设置分段下载
|
Request |
readTimeout(int readTimeoutMillis)
设置读取超时时间(毫秒)
|
Request |
referrer(String referrer)
指定referrer
|
Request |
requestBody(com.alibaba.fastjson.JSONArray body)
设置请求体内容
|
Request |
requestBody(com.alibaba.fastjson.JSONObject body)
设置请求体内容
|
Request |
requestBody(Path file)
设置请求体内容
|
Request |
requestBody(String body)
设置请求体内容
|
RequestMeta |
requestMeta() |
Request |
retryTimes(int retryTimes)
请求超时时重试次数
|
Request |
setHeader(String name,
String value)
设置头部字段信息
|
Request |
url(String url)
指定请求地址
|
Request |
url(URL url)
指定请求地址
|
Request |
userAgent(Request.UserAgent userAgent)
指定用户代理
|
Request |
userAgent(String userAgent)
指定用户代理
|
Request method(Request.Method method)
method - 请求方法Request basicAuth(String username, String password)
username - 用户名password - 密码Request userAgent(Request.UserAgent userAgent)
userAgent - 用户代理Request contentType(Request.ContentType contentType)
contentType - Content-Type头部Request ajax()
Request ranges(long start, long end)
start - 开始字节end - 结束字节(0表示获取剩下所有字节)Request acceptEncoding(boolean acceptEncoding)
acceptEncoding - 是否允许服务器开启文件压缩,默认允许Request cookie(HttpCookie httpCookie)
httpCookie - cookie信息Request cookie(List<HttpCookie> httpCookieList)
httpCookieList - cookie列表Request requestBody(com.alibaba.fastjson.JSONObject body)
body - 请求体Request requestBody(com.alibaba.fastjson.JSONArray body)
body - 请求体Request requestBody(Path file) throws IOException
file - 上传文件IOExceptionRequest connectTimeout(int connectTimeoutMillis)
connectTimeoutMillis - 连接超时时间(毫秒),0表示不限制Request readTimeout(int readTimeoutMillis)
readTimeoutMillis - 读取超时时间(毫秒),0表示不限制Request followRedirects(boolean followRedirects)
followRedirects - 是否自动重新定定向.默认为trueRequest maxFollowRedirectTimes(int maxFollowRedirectTimes)
maxFollowRedirectTimes - 最大重定向次数Request ignoreHttpErrors(boolean ignoreHttpErrors)
ignoreHttpErrors - 忽略http错误,默认为falseRequest retryTimes(int retryTimes)
retryTimes - 重试次数,默认为3次Response execute()
void enqueue(ResponseListener responseListener)
responseListener - 请求回调接口Request clone()
RequestMeta requestMeta()
Copyright © 2021. All rights reserved.