Package com.squareup.okhttp
Class Request.Builder
- java.lang.Object
-
- com.squareup.okhttp.Request.Builder
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Request.BuilderaddHeader(String name, String value)Adds a header withnameandvalue.Requestbuild()Request.BuildercacheControl(CacheControl cacheControl)Sets this request'sCache-Controlheader, replacing any cache control headers already present.Request.Builderdelete()Request.Builderdelete(RequestBody body)Request.Builderget()Request.Builderhead()Request.Builderheader(String name, String value)Sets the header namednametovalue.Request.Builderheaders(Headers headers)Removes all headers on this builder and addsheaders.Request.Buildermethod(String method, RequestBody body)Request.Builderpatch(RequestBody body)Request.Builderpost(RequestBody body)Request.Builderput(RequestBody body)Request.BuilderremoveHeader(String name)Request.Buildertag(Object tag)Attachestagto the request.Request.Builderurl(HttpUrl url)Request.Builderurl(String url)Sets the URL target of this request.Request.Builderurl(URL url)Sets the URL target of this request.
-
-
-
Method Detail
-
url
public Request.Builder url(HttpUrl url)
-
url
public Request.Builder url(String url)
Sets the URL target of this request.- Throws:
IllegalArgumentException- ifurlis not a valid HTTP or HTTPS URL. Avoid this exception by callingHttpUrl.parse(java.lang.String); it returns null for invalid URLs.
-
url
public Request.Builder url(URL url)
Sets the URL target of this request.- Throws:
IllegalArgumentException- if the scheme ofurlis nothttporhttps.
-
header
public Request.Builder header(String name, String value)
Sets the header namednametovalue. If this request already has any headers with that name, they are all replaced.
-
addHeader
public Request.Builder addHeader(String name, String value)
Adds a header withnameandvalue. Prefer this method for multiply-valued headers like "Cookie".
-
removeHeader
public Request.Builder removeHeader(String name)
-
headers
public Request.Builder headers(Headers headers)
Removes all headers on this builder and addsheaders.
-
cacheControl
public Request.Builder cacheControl(CacheControl cacheControl)
Sets this request'sCache-Controlheader, replacing any cache control headers already present. IfcacheControldoesn't define any directives, this clears this request's cache-control headers.
-
get
public Request.Builder get()
-
head
public Request.Builder head()
-
post
public Request.Builder post(RequestBody body)
-
delete
public Request.Builder delete(RequestBody body)
-
delete
public Request.Builder delete()
-
put
public Request.Builder put(RequestBody body)
-
patch
public Request.Builder patch(RequestBody body)
-
method
public Request.Builder method(String method, RequestBody body)
-
tag
public Request.Builder tag(Object tag)
Attachestagto 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.
-
build
public Request build()
-
-