request

fun OkHttpClient.request(url: String, method: HttpMethod = HttpMethod.GET, body: RequestBody? = null, headers: Headers = Headers.headersOf(), userAgent: String? = null): Call

Creates a generic HTTP request.

Return

A Call object representing the request.

Parameters

url

The URL for the request.

method

The HTTP method for the request.

body

The body data to be sent with the request.

headers

The headers for the request.

userAgent

The User-Agent header for the request.


fun OkHttpClient.request(url: URL, method: HttpMethod = HttpMethod.GET, body: RequestBody? = null, headers: Headers = Headers.headersOf(), userAgent: String? = null): Call

Creates an OkHttp Call for a request with the specified URL.

This is a convenience function that delegates to request with a String URL.

Return

An OkHttp Call object representing the request.

Parameters

url

The URL of the request.

method

The HTTP method (default: GET).

body

The request body (optional).

headers

The request headers (optional).

userAgent

The user agent for the request (optional).


fun OkHttpClient.request(url: HttpUrl, method: HttpMethod = HttpMethod.GET, body: RequestBody? = null, headers: Headers = Headers.headersOf(), userAgent: String? = null): Call

Creates an OkHttp Call for a request with the specified HttpUrl.

This is a convenience function that delegates to request with a String URL.

Return

An OkHttp Call object representing the request.

Parameters

url

The HttpUrl of the request.

method

The HTTP method (default: GET).

body

The request body (optional).

headers

The request headers (optional).

userAgent

The user agent for the request (optional).