| Constructor and Description |
|---|
Builder()
|
| Modifier and Type | Method and Description |
|---|---|
Request |
addHeader(String
Adds a header with
name and
value.
|
Request |
build()
|
Request |
cacheControl(CacheControl
Sets this request's
Cache-Control header, replacing any cache control headers already present.
|
Request |
delete()
|
Request |
delete(RequestBody
|
Request |
get()
|
Request |
head()
|
Request |
header(String
Sets the header named
name to
value.
|
Request |
headers(Headers
Removes all headers on this builder and adds
headers.
|
Request |
method(String
|
Request |
patch(RequestBody
|
Request |
post(RequestBody
|
Request |
put(RequestBody
|
Request |
removeHeader(String
|
Request |
tag(Object
Attaches
tag to the request.
|
Request |
url(HttpUrl
|
Request |
url(String
Sets the URL target of this request.
|
Request |
url(URL
Sets the URL target of this request.
|
public Request.Builder url(HttpUrl url)
public Request.Builder 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 Request.Builder url(URL url)
IllegalArgumentException - if the scheme of
url is not
http or
https.
public Request.Builder header(String name, String value)
name to
value. If this request already has any headers with that name, they are all replaced.
public Request.Builder 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.
public Request.Builder removeHeader(String name)
public Request.Builder headers(Headers headers)
headers.
public Request.Builder cacheControl(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 Request.Builder get()
public Request.Builder head()
public Request.Builder post(RequestBody body)
public Request.Builder delete(RequestBody body)
public Request.Builder delete()
public Request.Builder put(RequestBody body)
public Request.Builder patch(RequestBody body)
public Request.Builder method(String method, RequestBody body)
public Request.Builder tag(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 Requestbuild()