okhttp / okhttp3 / Request / Builder

Builder

class Builder

Constructors

<init>

Builder()

Functions

addHeader

open fun addHeader(name: String, value: String): Request.Builder

Adds a header with name and value. Prefer this method for multiply-valued headers like "Cookie".

build

open fun build(): Request

cacheControl

open fun cacheControl(cacheControl: CacheControl): Request.Builder

Sets this request's 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.

delete

open fun delete(body: RequestBody? = EMPTY_REQUEST): Request.Builder

get

open fun get(): Request.Builder

head

open fun head(): Request.Builder

header

open fun header(name: String, value: String): Request.Builder

Sets the header named name to value. If this request already has any headers with that name, they are all replaced.

headers

open fun headers(headers: Headers): Request.Builder

Removes all headers on this builder and adds headers.

method

open fun method(method: String, body: RequestBody?): Request.Builder

patch

open fun patch(body: RequestBody): Request.Builder

post

open fun post(body: RequestBody): Request.Builder

put

open fun put(body: RequestBody): Request.Builder

removeHeader

open fun removeHeader(name: String): Request.Builder

Removes all headers named name on this builder.

tag

open fun tag(tag: Any?): Request.Builder

Attaches tag to the request using Object.class as a key.

open fun <T> tag(type: Class<in T>, tag: T?): Request.Builder

Attaches 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.

url

open fun url(url: HttpUrl): Request.Builderopen fun url(url: String): Request.Builder
open fun url(url: URL): Request.Builder

Sets the URL target of this request.