HttpRequest

An immutable request: method, URL, headers and an optional body.

Stable Core. Built with the factory HttpRequest(method, url) { headers = ...; body = ... }. The factory refuses, with IllegalArgumentException and in this order: the method CONNECT; a header value that is not sendable (HTAB or U+0020..U+007E); a body on GET, HEAD or TRACE; a body with a content type beside a Content-Type header. Equality is identity. toString() prints the method, the redacted URL, the header names and the body's size, never a header value or the body.

Types

Link copied to clipboard

Collects the optional parts of an HttpRequest. Not thread-safe; use it only inside the factory's lambda.

Properties

Link copied to clipboard

The body, or null for none.

Link copied to clipboard

The headers; empty when none were set.

Link copied to clipboard

The method.

Link copied to clipboard
val url: Url

The URL.

Functions

Link copied to clipboard
open override fun toString(): String

A diagnostic string for logs: method, the url in its redacted form (Url.redacted), the headers' names and the body's size, never a header value or the body. Its format is not part of the API and may change.