Package-level declarations

Types

Link copied to clipboard
class Address(uriHost: String, uriPort: Int, val dns: Dns, val socketFactory: SocketFactory, val sslSocketFactory: SSLSocketFactory?, val hostnameVerifier: HostnameVerifier?, val certificatePinner: CertificatePinner?, val proxyAuthenticator: Authenticator, val proxy: Proxy?, protocols: List<Protocol>, connectionSpecs: List<ConnectionSpec>, val proxySelector: ProxySelector)

A specification for a connection to an origin server. For simple connections, this is the server's hostname and port. If an explicit proxy is requested (or no proxy is explicitly requested), this also includes that proxy information. For secure connections the address also includes the SSL socket factory, hostname verifier, and certificate pinner.

Link copied to clipboard

An async domain name service that resolves IP addresses for host names.

Link copied to clipboard
fun interface Authenticator

Performs either preemptive authentication before connecting to a proxy server, or reactive authentication after receiving a challenge from either an origin web server or proxy server.

Link copied to clipboard

Caches HTTP and HTTPS responses to the filesystem so they may be reused, saving time and bandwidth.

Link copied to clipboard

A Cache-Control header with cache directives from a server or client. These directives set policy on what responses can be stored, and which requests can be satisfied by those stored responses.

Link copied to clipboard
interface Call : Cloneable

A call is a request that has been prepared for execution. A call can be canceled. As this object represents a single request/response pair (stream), it cannot be executed twice.

Link copied to clipboard
interface Callback
Link copied to clipboard

Constrains which certificates are trusted. Pinning certificates defends against attacks on certificate authorities. It also prevents connections through man-in-the-middle certificate authorities either known or unknown to the application's user. This class currently pins a certificate's Subject Public Key Info as described on Adam Langley's Weblog. Pins are either base64 SHA-256 hashes as in HTTP Public Key Pinning (HPKP) or SHA-1 base64 hashes as in Chromium's static certificates.

Link copied to clipboard
class Challenge(val scheme: String, authParams: Map<String?, String>)

An RFC 7235 challenge.

Link copied to clipboard
Link copied to clipboard
interface Connection

The sockets and streams of an HTTP, HTTPS, or HTTPS+HTTP/2 connection. May be used for multiple HTTP request/response exchanges. Connections may be direct to the origin server or via a proxy.

Link copied to clipboard

Listener for connection events. Extend this class to monitor the new connections and closes.

Link copied to clipboard

Manages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that share the same Address may share a Connection. This class implements the policy of which connections to keep open for future use.

Link copied to clipboard

Specifies configuration for the socket connection that HTTP traffic travels through. For https: URLs, this includes the TLS version and cipher suites to use when negotiating a secure connection.

Link copied to clipboard
class Cookie

An RFC 6265 Cookie.

Link copied to clipboard
interface CookieJar

Provides policy and persistence for HTTP cookies.

Link copied to clipboard

Factory for HTTP authorization credentials.

Link copied to clipboard

Policy on when async requests are executed.

Link copied to clipboard
fun interface Dns

A domain name service that resolves IP addresses for host names. Most applications will use the system DNS service, which is the default. Some applications may provide their own implementation to use a different DNS server, to prefer IPv6 addresses, to prefer IPv4 addresses, or to force a specific known IP address.

Link copied to clipboard
abstract class EventListener

Listener for metrics events. Extend this class to monitor the quantity, size, and duration of your application's HTTP calls.

Link copied to clipboard

Marks declarations that are experimental and subject to change without following SemVer conventions. Both binary and source-incompatible changes are possible, including complete removal of the experimental API.

Link copied to clipboard
Link copied to clipboard
class Handshake

A record of a TLS handshake. For HTTPS clients, the client is local and the remote server is its peer.

Link copied to clipboard

The header fields of a single HTTP message. Values are uninterpreted strings; use Request and Response for interpreted headers. This class maintains the order of the header fields within the HTTP message.

Link copied to clipboard
class HttpUrl

A uniform resource locator (URL) with a scheme of either http or https. Use this class to compose and decompose Internet addresses. For example, this code will compose and print a URL for Google search:

Link copied to clipboard
fun interface Interceptor

Observes, modifies, and potentially short-circuits requests going out and the corresponding responses coming back in. Typically interceptors add, remove, or transform headers on the request or response.

Link copied to clipboard
class MediaType

An RFC 2045 Media Type, appropriate to describe the content type of an HTTP request or response body.

Link copied to clipboard

An RFC 2387-compliant request body.

Link copied to clipboard
class MultipartReader constructor(source: BufferedSource, val boundary: String) : Closeable

Reads a stream of RFC 2046 multipart body parts. Callers read parts one-at-a-time until nextPart returns null. After calling nextPart any preceding parts should not be read.

Link copied to clipboard
object OkHttp
Link copied to clipboard

Factory for calls, which can be used to send HTTP requests and read their responses.

Link copied to clipboard

Protocols that OkHttp implements for ALPN selection.

Link copied to clipboard
class Request

An HTTP request. Instances of this class are immutable if their body is null or itself immutable.

Link copied to clipboard
abstract class RequestBody
Link copied to clipboard

An HTTP response. Instances of this class are not immutable: the response body is a one-shot value that may be consumed only once and then closed. All other properties are immutable.

Link copied to clipboard
abstract class ResponseBody : Closeable

A one-shot stream from the origin server to the client application with the raw bytes of the response body. Each response body is supported by an active connection to the webserver. This imposes both obligations and limits on the client application.

Link copied to clipboard
class Route(val address: Address, val proxy: Proxy, val socketAddress: InetSocketAddress)

The concrete route used by a connection to reach an abstract origin server. When creating a connection the client has many options:

Link copied to clipboard

Versions of TLS that can be offered when negotiating a secure socket. See javax.net.ssl.SSLSocket.setEnabledProtocols.

Link copied to clipboard
interface WebSocket

A non-blocking interface to a web socket. Use the factory to create instances; usually this is OkHttpClient.

Link copied to clipboard
abstract class WebSocketListener