public final class OkHttpRequest extends Object
| Modifier and Type | Method and Description |
|---|---|
OkHttpRequest |
addHeader(String name,
String value)
Deprecated.
no use case?
|
OkHttpRequest |
basicAuth(String user,
Object password) |
OkHttpRequest |
body(byte[] content,
int offset,
int byteCount,
okhttp3.MediaType contentType) |
OkHttpRequest |
body(byte[] content,
okhttp3.MediaType contentType) |
OkHttpRequest |
body(File content,
okhttp3.MediaType contentType) |
OkHttpRequest |
body(Map<?,?> formBodyByMap)
Deprecated.
replaced by
formBody(Map). |
OkHttpRequest |
body(Object formBodyByEntity)
Deprecated.
replaced by
formBody(Object). |
OkHttpRequest |
body(okhttp3.RequestBody body) |
OkHttpRequest |
body(String content,
okhttp3.MediaType contentType) |
OkHttpRequest |
cacheControl(okhttp3.CacheControl cacheControl)
Sets this request's
Cache-Control header, replacing any cache control headers already
present. |
static OkHttpRequest |
create(okhttp3.HttpUrl url,
okhttp3.OkHttpClient httpClient) |
static OkHttpRequest |
create(String url,
okhttp3.OkHttpClient httpClient) |
static OkHttpRequest |
create(URL url,
okhttp3.OkHttpClient httpClient) |
okhttp3.Response |
delete() |
<T> T |
delete(Class<T> resultClass) |
<T> T |
execute(Class<T> resultClass,
HttpMethod httpMethod) |
okhttp3.Response |
execute(HttpMethod httpMethod) |
OkHttpRequest |
formBody(Map<?,?> formBodyByMap) |
OkHttpRequest |
formBody(Object formBodyByEntity) |
okhttp3.Response |
get() |
<T> T |
get(Class<T> resultClass) |
okhttp3.Response |
head() |
OkHttpRequest |
header(String name,
String value)
Sets the header named
name to value. |
OkHttpRequest |
headers(okhttp3.Headers headers)
Removes all headers on this builder and adds
headers |
OkHttpRequest |
headers(Map<String,?> headers)
Set http headers specified by the key/value entities from
Map. |
OkHttpRequest |
headers(String name1,
String value1,
String name2,
String value2)
Set http headers specified by
name1/value1, name2/value2. |
OkHttpRequest |
headers(String name1,
String value1,
String name2,
String value2,
String name3,
String value3)
Set http headers specified by
name1/value1, name2/value2, name3/value3. |
OkHttpRequest |
jsonBody(Object obj) |
OkHttpRequest |
jsonBody(String json) |
okhttp3.Response |
patch() |
<T> T |
patch(Class<T> resultClass) |
okhttp3.Response |
post() |
<T> T |
post(Class<T> resultClass) |
okhttp3.Response |
put() |
<T> T |
put(Class<T> resultClass) |
OkHttpRequest |
removeHeader(String name)
Deprecated.
no use case?
|
<T> OkHttpRequest |
tag(Class<? super T> type,
T tag)
Attaches
tag to the request using type as a key. |
OkHttpRequest |
tag(Object tag)
Attaches
tag to the request. |
static OkHttpRequest |
url(okhttp3.HttpUrl url) |
static OkHttpRequest |
url(okhttp3.HttpUrl url,
long connectionTimeoutInMillis,
long readTimeoutInMillis) |
static OkHttpRequest |
url(String url)
Sets the URL target of this request.
|
static OkHttpRequest |
url(String url,
long connectionTimeoutInMillis,
long readTimeoutInMillis) |
static OkHttpRequest |
url(URL url)
Sets the URL target of this request.
|
static OkHttpRequest |
url(URL url,
long connectionTimeoutInMillis,
long readTimeoutInMillis) |
public static OkHttpRequest create(String url, okhttp3.OkHttpClient httpClient)
public static OkHttpRequest create(URL url, okhttp3.OkHttpClient httpClient)
public static OkHttpRequest create(okhttp3.HttpUrl url, okhttp3.OkHttpClient httpClient)
public static OkHttpRequest url(String url)
IllegalArgumentException - if url is not a valid HTTP or HTTPS URL. Avoid this
exception by calling HttpUrl.parse(java.lang.String); it returns null for invalid URLs.public static OkHttpRequest url(URL url)
IllegalArgumentException - if the scheme of url is not http or https.public static OkHttpRequest url(okhttp3.HttpUrl url)
public static OkHttpRequest url(String url, long connectionTimeoutInMillis, long readTimeoutInMillis)
public static OkHttpRequest url(URL url, long connectionTimeoutInMillis, long readTimeoutInMillis)
public static OkHttpRequest url(okhttp3.HttpUrl url, long connectionTimeoutInMillis, long readTimeoutInMillis)
public OkHttpRequest cacheControl(okhttp3.CacheControl cacheControl)
Cache-Control header, replacing any cache control headers already
present. If cacheControl doesn't define any directives, this clears this request's
cache-control headers.public OkHttpRequest tag(@Nullable Object tag)
tag to the request. It can be used later to cancel the request. If the tag
is unspecified or null, the request is canceled by using the request itself as the tag.public <T> OkHttpRequest tag(Class<? super T> type, @Nullable T tag)
tag to the request using type as a key. Tags can be read from a
request using Request.tag(). Use null to remove any existing tag assigned for type.
Use this API to attach timing, debugging, or other application data to a request so that you may read it in interceptors, event listeners, or callbacks.
public OkHttpRequest basicAuth(String user, Object password)
user - password - public OkHttpRequest header(String name, String value)
name to value.
If this request already has any headers with that name, they are all replaced.name - value - Request.Builder#header(String, String)public OkHttpRequest headers(String name1, String value1, String name2, String value2)
name1/value1, name2/value2.
If this request already has any headers with that name, they are all replaced.name1 - value1 - name2 - value2 - Request.Builder#header(String, String)public OkHttpRequest headers(String name1, String value1, String name2, String value2, String name3, String value3)
name1/value1, name2/value2, name3/value3.
If this request already has any headers with that name, they are all replaced.name1 - value1 - name2 - value2 - name3 - value3 - Request.Builder#header(String, String)public OkHttpRequest headers(Map<String,?> headers)
Map.
If this request already has any headers with that name, they are all replaced.headers - Request.Builder#header(String, String)public OkHttpRequest headers(okhttp3.Headers headers)
headersheaders - Request.Builder#headers(Headers)@Deprecated public OkHttpRequest addHeader(String name, String value)
name and value. Prefer this method for multiply-valued
headers like "Cookie".
Note that for some headers including Content-Length and Content-Encoding,
OkHttp may replace value with a header derived from the request body.
@Deprecated public OkHttpRequest removeHeader(String name)
name - public OkHttpRequest jsonBody(String json)
json - public OkHttpRequest jsonBody(Object obj)
obj - public OkHttpRequest formBody(Map<?,?> formBodyByMap)
formBodyByMap - FormBody.Builder}public OkHttpRequest formBody(Object formBodyByEntity)
formBodyByEntity - FormBody.Builder}@Deprecated public OkHttpRequest body(Map<?,?> formBodyByMap)
formBody(Map).formBodyByMap - FormBody.Builder}@Deprecated public OkHttpRequest body(Object formBodyByEntity)
formBody(Object).formBodyByEntity - FormBody.Builder}public OkHttpRequest body(okhttp3.RequestBody body)
body - RequestBody}public OkHttpRequest body(String content, @Nullable okhttp3.MediaType contentType)
content - contentType - RequestBody.create(MediaType, String)public OkHttpRequest body(byte[] content, @Nullable okhttp3.MediaType contentType)
content - contentType - RequestBody.create(MediaType, byte[])public OkHttpRequest body(byte[] content, int offset, int byteCount, @Nullable okhttp3.MediaType contentType)
content - offset - len - contentType - RequestBody.create(MediaType, byte[], int, int)public OkHttpRequest body(File content, @Nullable okhttp3.MediaType contentType)
content - contentType - public okhttp3.Response get()
throws IOException
IOExceptionpublic <T> T get(Class<T> resultClass) throws IOException
IOExceptionpublic okhttp3.Response post()
throws IOException
IOExceptionpublic <T> T post(Class<T> resultClass) throws IOException
IOExceptionpublic okhttp3.Response put()
throws IOException
IOExceptionpublic <T> T put(Class<T> resultClass) throws IOException
IOExceptionpublic okhttp3.Response patch()
throws IOException
IOExceptionpublic <T> T patch(Class<T> resultClass) throws IOException
IOExceptionpublic okhttp3.Response delete()
throws IOException
IOExceptionpublic <T> T delete(Class<T> resultClass) throws IOException
IOExceptionpublic okhttp3.Response head()
throws IOException
IOExceptionpublic okhttp3.Response execute(HttpMethod httpMethod) throws IOException
IOExceptionpublic <T> T execute(Class<T> resultClass, HttpMethod httpMethod) throws IOException
IOExceptionCopyright © 2021. All rights reserved.