Package com.landawn.abacus.http
Class OkHttpRequest
java.lang.Object
com.landawn.abacus.http.OkHttpRequest
Note: This class contains the codes and docs copied from OkHttp: https://square.github.io/okhttp/ under Apache License v2.
- Since:
- 1.3
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.no use case?ContinuableFuture<okhttp3.Response>
<T> ContinuableFuture<T>
asyncDelete
(Class<T> resultClass) <T> ContinuableFuture<T>
asyncDelete
(Class<T> resultClass, Executor executor) ContinuableFuture<okhttp3.Response>
asyncDelete
(Executor executor) ContinuableFuture<okhttp3.Response>
asyncExecute
(HttpMethod httpMethod) ContinuableFuture<okhttp3.Response>
asyncExecute
(HttpMethod httpMethod, Executor executor) <T> ContinuableFuture<T>
asyncExecute
(Class<T> resultClass, HttpMethod httpMethod) <T> ContinuableFuture<T>
asyncExecute
(Class<T> resultClass, HttpMethod httpMethod, Executor executor) ContinuableFuture<okhttp3.Response>
asyncGet()
<T> ContinuableFuture<T>
<T> ContinuableFuture<T>
ContinuableFuture<okhttp3.Response>
ContinuableFuture<okhttp3.Response>
ContinuableFuture<okhttp3.Response>
ContinuableFuture<okhttp3.Response>
<T> ContinuableFuture<T>
asyncPatch
(Class<T> resultClass) <T> ContinuableFuture<T>
asyncPatch
(Class<T> resultClass, Executor executor) ContinuableFuture<okhttp3.Response>
asyncPatch
(Executor executor) ContinuableFuture<okhttp3.Response>
<T> ContinuableFuture<T>
<T> ContinuableFuture<T>
ContinuableFuture<okhttp3.Response>
ContinuableFuture<okhttp3.Response>
asyncPut()
<T> ContinuableFuture<T>
<T> ContinuableFuture<T>
ContinuableFuture<okhttp3.Response>
body
(byte[] content, int offset, int byteCount, okhttp3.MediaType contentType) body
(byte[] content, okhttp3.MediaType contentType) Deprecated.replaced byformBody(Object)
.Deprecated.replaced byformBody(Map)
.body
(okhttp3.RequestBody body) cacheControl
(okhttp3.CacheControl cacheControl) Sets this request'sCache-Control
header, replacing any cache control headers already present.static OkHttpRequest
static OkHttpRequest
static OkHttpRequest
create
(okhttp3.HttpUrl url, okhttp3.OkHttpClient httpClient) okhttp3.Response
delete()
<T> T
okhttp3.Response
execute
(HttpMethod httpMethod) <T> T
execute
(Class<T> resultClass, HttpMethod httpMethod) okhttp3.Response
get()
<T> T
okhttp3.Response
head()
Sets the header namedname
tovalue
.headers
(HttpHeaders headers) Removes all headers on this builder and addsheaders
Set http headers specified byname1/value1
,name2/value2
.Set http headers specified byname1/value1
,name2/value2
,name3/value3
.Set http headers specified by the key/value entities fromMap
.headers
(okhttp3.Headers headers) Removes all headers on this builder and addsheaders
okhttp3.Response
patch()
<T> T
okhttp3.Response
post()
<T> T
okhttp3.Response
put()
<T> T
removeHeader
(String name) Deprecated.no use case?<T> OkHttpRequest
Attachestag
to the request usingtype
as a key.Attachestag
to the request.static OkHttpRequest
Sets the URL target of this request.static OkHttpRequest
static OkHttpRequest
Sets the URL target of this request.static OkHttpRequest
static OkHttpRequest
url
(okhttp3.HttpUrl url) static OkHttpRequest
url
(okhttp3.HttpUrl url, long connectionTimeoutInMillis, long readTimeoutInMillis)
-
Method Details
-
create
-
create
-
create
-
url
Sets the URL target of this request.- Throws:
IllegalArgumentException
- ifurl
is not a valid HTTP or HTTPS URL. Avoid this exception by callingHttpUrl.parse(java.lang.String)
; it returns null for invalid URLs.
-
url
Sets the URL target of this request.- Throws:
IllegalArgumentException
- if the scheme ofurl
is nothttp
orhttps
.
-
url
-
url
public static OkHttpRequest url(String url, long connectionTimeoutInMillis, long readTimeoutInMillis) -
url
-
url
public static OkHttpRequest url(okhttp3.HttpUrl url, long connectionTimeoutInMillis, long readTimeoutInMillis) -
cacheControl
Sets this request'sCache-Control
header, replacing any cache control headers already present. IfcacheControl
doesn't define any directives, this clears this request's cache-control headers. -
tag
Attachestag
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. -
tag
Attachestag
to the request usingtype
as a key. Tags can be read from a request usingRequest.tag()
. Use null to remove any existing tag assigned fortype
.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.
-
basicAuth
- Parameters:
user
-password
-- Returns:
-
header
Sets the header namedname
tovalue
. If this request already has any headers with that name, they are all replaced.- Parameters:
name
-value
-- Returns:
- See Also:
-
Request.Builder.header(String, String)
-
headers
Set http headers specified byname1/value1
,name2/value2
. If this request already has any headers with that name, they are all replaced.- Parameters:
name1
-value1
-name2
-value2
-- Returns:
- See Also:
-
Request.Builder.header(String, String)
-
headers
public OkHttpRequest headers(String name1, String value1, String name2, String value2, String name3, String value3) Set http headers specified byname1/value1
,name2/value2
,name3/value3
. If this request already has any headers with that name, they are all replaced.- Parameters:
name1
-value1
-name2
-value2
-name3
-value3
-- Returns:
- See Also:
-
Request.Builder.header(String, String)
-
headers
Set http headers specified by the key/value entities fromMap
. If this request already has any headers with that name, they are all replaced.- Parameters:
headers
-- Returns:
- See Also:
-
Request.Builder.header(String, String)
-
headers
Removes all headers on this builder and addsheaders
- Parameters:
headers
-- Returns:
- See Also:
-
Request.Builder.headers(Headers)
-
headers
Removes all headers on this builder and addsheaders
- Parameters:
headers
-- Returns:
- See Also:
-
Request.Builder.headers(Headers)
-
addHeader
Deprecated.no use case?Adds a header withname
andvalue
. Prefer this method for multiply-valued headers like "Cookie".Note that for some headers including
Content-Length
andContent-Encoding
, OkHttp may replacevalue
with a header derived from the request body. -
removeHeader
Deprecated.no use case?- Parameters:
name
-- Returns:
-
jsonBody
- Parameters:
json
-- Returns:
-
jsonBody
- Parameters:
obj
-- Returns:
-
formBody
- Parameters:
formBodyByMap
-- Returns:
-
formBody
- Parameters:
formBodyByEntity
-- Returns:
-
body
Deprecated.replaced byformBody(Map)
.- Parameters:
formBodyByMap
-- Returns:
-
body
Deprecated.replaced byformBody(Object)
.- Parameters:
formBodyByEntity
-- Returns:
-
body
- Parameters:
body
-- Returns:
-
body
- Parameters:
content
-contentType
-- Returns:
- See Also:
-
RequestBody.create(MediaType, String)
-
body
- Parameters:
content
-contentType
-- Returns:
- See Also:
-
RequestBody.create(MediaType, byte[])
-
body
public OkHttpRequest body(byte[] content, int offset, int byteCount, @Nullable okhttp3.MediaType contentType) - Parameters:
content
-offset
-len
-contentType
-- Returns:
- See Also:
-
RequestBody.create(MediaType, byte[], int, int)
-
body
- Parameters:
content
-contentType
-- Returns:
-
get
- Throws:
IOException
-
get
- Throws:
IOException
-
post
- Throws:
IOException
-
post
- Throws:
IOException
-
put
- Throws:
IOException
-
put
- Throws:
IOException
-
patch
- Throws:
IOException
-
patch
- Throws:
IOException
-
delete
- Throws:
IOException
-
delete
- Throws:
IOException
-
head
- Throws:
IOException
-
execute
- Throws:
IOException
-
execute
- Throws:
IOException
-
asyncGet
-
asyncGet
-
asyncGet
-
asyncGet
-
asyncPost
-
asyncPost
-
asyncPost
-
asyncPost
-
asyncPut
-
asyncPut
-
asyncPut
-
asyncPut
-
asyncPatch
-
asyncPatch
-
asyncPatch
-
asyncPatch
-
asyncDelete
-
asyncDelete
-
asyncDelete
-
asyncDelete
-
asyncHead
-
asyncHead
-
asyncExecute
-
asyncExecute
-
asyncExecute
-
asyncExecute
public <T> ContinuableFuture<T> asyncExecute(Class<T> resultClass, HttpMethod httpMethod, Executor executor)
-