Package com.qiniu.http
Class Client
- java.lang.Object
-
- com.qiniu.http.Client
-
public final class Client extends java.lang.Object
定义HTTP请求管理相关方法
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ContentTypeHeader
static java.lang.String
DefaultMime
static java.lang.String
FormMime
static java.lang.String
JsonMime
-
Constructor Summary
Constructors Constructor Description Client()
构建一个默认配置的 HTTP Client 类Client(Dns dns, boolean hostFirst, ProxyConfiguration proxy, int connTimeout, int readTimeout, int writeTimeout, int dispatcherMaxRequests, int dispatcherMaxRequestsPerHost, int connectionPoolMaxIdleCount, int connectionPoolMaxIdleMinutes)
构建一个自定义配置的 HTTP Client 类Client(Configuration cfg)
Client(Configuration cfg)
构建一个自定义配置的 HTTP Client 类
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
asyncMultipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, byte[] fileBody, java.lang.String mimeType, StringMap headers, AsyncCallback cb)
void
asyncMultipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, java.io.File fileBody, java.lang.String mimeType, StringMap headers, AsyncCallback cb)
void
asyncPost(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType, AsyncCallback cb)
void
asyncSend(okhttp3.Request.Builder requestBuilder, StringMap headers, AsyncCallback cb)
Response
delete(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType)
Response
delete(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType)
Response
delete(java.lang.String url, StringMap headers)
Response
delete(java.lang.String url, okhttp3.RequestBody body, StringMap headers)
Response
get(java.lang.String url)
Response
get(java.lang.String url, StringMap headers)
Response
multipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, byte[] fileBody, java.lang.String mimeType, StringMap headers)
Response
multipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, java.io.File fileBody, java.lang.String mimeType, StringMap headers)
Response
patch(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType)
Response
patch(java.lang.String url, byte[] body, StringMap headers)
Response
patch(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType)
Response
patch(java.lang.String url, StringMap params, StringMap headers)
Response
patch(java.lang.String url, java.lang.String body, StringMap headers)
Response
post(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType)
Response
post(java.lang.String url, byte[] body, StringMap headers)
Response
post(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType)
Response
post(java.lang.String url, StringMap params, StringMap headers)
Response
post(java.lang.String url, java.lang.String body, StringMap headers)
Response
post(java.lang.String url, okhttp3.RequestBody body, StringMap headers)
Response
put(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType)
Response
put(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType)
Response
put(java.lang.String url, okhttp3.RequestBody body, StringMap headers)
Response
send(okhttp3.Request.Builder requestBuilder, StringMap headers)
static void
setAppName(java.lang.String userApp)
-
-
-
Field Detail
-
ContentTypeHeader
public static final java.lang.String ContentTypeHeader
- See Also:
- Constant Field Values
-
DefaultMime
public static final java.lang.String DefaultMime
- See Also:
- Constant Field Values
-
JsonMime
public static final java.lang.String JsonMime
- See Also:
- Constant Field Values
-
FormMime
public static final java.lang.String FormMime
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Client
public Client()
构建一个默认配置的 HTTP Client 类
-
Client
public Client(Configuration cfg)
构建一个自定义配置的 HTTP Client 类- Parameters:
cfg
- 配置信息
-
Client
public Client(Configuration cfg)
-
Client
public Client(Dns dns, boolean hostFirst, ProxyConfiguration proxy, int connTimeout, int readTimeout, int writeTimeout, int dispatcherMaxRequests, int dispatcherMaxRequestsPerHost, int connectionPoolMaxIdleCount, int connectionPoolMaxIdleMinutes)
构建一个自定义配置的 HTTP Client 类- Parameters:
dns
- dns 解析类hostFirst
- 是否优先使用 hostproxy
- 代理connTimeout
- 链接超时readTimeout
- 读超时writeTimeout
- 写超时dispatcherMaxRequests
- 并发最大请求数dispatcherMaxRequestsPerHost
- 单 Host 并发最大请求数connectionPoolMaxIdleCount
- 连接池中请求最大空闲数connectionPoolMaxIdleMinutes
- 连接池中请求最大空闲分钟数
-
-
Method Detail
-
setAppName
public static void setAppName(java.lang.String userApp)
-
get
public Response get(java.lang.String url) throws QiniuException
- Throws:
QiniuException
-
get
public Response get(java.lang.String url, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
delete
public Response delete(java.lang.String url, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
delete
public Response delete(java.lang.String url, okhttp3.RequestBody body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
delete
public Response delete(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
delete
public Response delete(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, byte[] body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, java.lang.String body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, StringMap params, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
put
public Response put(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
put
public Response put(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
post
public Response post(java.lang.String url, okhttp3.RequestBody body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
put
public Response put(java.lang.String url, okhttp3.RequestBody body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
multipartPost
public Response multipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, byte[] fileBody, java.lang.String mimeType, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
multipartPost
public Response multipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, java.io.File fileBody, java.lang.String mimeType, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
patch
public Response patch(java.lang.String url, byte[] body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
patch
public Response patch(java.lang.String url, java.lang.String body, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
patch
public Response patch(java.lang.String url, StringMap params, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
patch
public Response patch(java.lang.String url, byte[] body, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
patch
public Response patch(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType) throws QiniuException
- Throws:
QiniuException
-
send
public Response send(okhttp3.Request.Builder requestBuilder, StringMap headers) throws QiniuException
- Throws:
QiniuException
-
asyncSend
public void asyncSend(okhttp3.Request.Builder requestBuilder, StringMap headers, AsyncCallback cb)
-
asyncPost
public void asyncPost(java.lang.String url, byte[] body, int offset, int size, StringMap headers, java.lang.String contentType, AsyncCallback cb)
-
asyncMultipartPost
public void asyncMultipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, byte[] fileBody, java.lang.String mimeType, StringMap headers, AsyncCallback cb)
-
asyncMultipartPost
public void asyncMultipartPost(java.lang.String url, StringMap fields, java.lang.String name, java.lang.String fileName, java.io.File fileBody, java.lang.String mimeType, StringMap headers, AsyncCallback cb) throws QiniuException
- Throws:
QiniuException
-
-