Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
Request.Builder |
addHeader(String name,
String value)
Adds a header with
name and value . |
Request |
build() |
Request.Builder |
cacheControl(CacheControl cacheControl)
Sets this request's
Cache-Control header, replacing any cache control headers already
present. |
Request.Builder |
delete() |
Request.Builder |
delete(RequestBody body) |
Request.Builder |
get() |
Request.Builder |
head() |
Request.Builder |
header(String name,
String value)
Sets the header named
name to value . |
Request.Builder |
headers(Headers headers)
Removes all headers on this builder and adds
headers . |
Request.Builder |
method(String method,
RequestBody body) |
Request.Builder |
patch(RequestBody body) |
Request.Builder |
post(RequestBody body) |
Request.Builder |
put(RequestBody body) |
Request.Builder |
removeHeader(String name) |
Request.Builder |
tag(Object tag)
Attaches
tag to the request. |
Request.Builder |
url(HttpUrl url) |
Request.Builder |
url(String url)
Sets the URL target of this request.
|
Request.Builder |
url(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 Request build()
Copyright © 2017. All Rights Reserved.