HttpHeaders

An immutable, ordered list of header entries. Names are RFC 9110 tokens and values obey the container rule (after trimming SP and HTAB at the ends, no CR, LF or NUL); both are checked by the Builder. Lookup folds ASCII letters only.

Stable Core. Built with the factory HttpHeaders { add(name, value) }. Equality is on the ordered entries (name spelling, value and sensitivity). toString() prints the names in order, with * after each sensitive entry, and never a value. A transport that receives entries this type cannot hold drops an entry whose name is not a token, replaces CR, LF and NUL in a value with SP, and keeps everything else in order.

Types

Link copied to clipboard

Collects entries for an HttpHeaders. Not thread-safe; use it only inside the factory's lambda.

Link copied to clipboard
class Entry

One header line: its name (spelling kept), its value (trimmed of SP and HTAB at the ends) and whether it is sensitive.

Properties

Link copied to clipboard
val size: Int

The number of entries.

Functions

Link copied to clipboard
operator fun contains(name: String): Boolean

Whether there is an entry named name, compared with an ASCII-only fold.

Link copied to clipboard

Returns the entries.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Two HttpHeaders are equal when their ordered entries are equal: name spelling, value and sensitivity.

Link copied to clipboard
operator fun get(name: String): String?

Returns the last value of name, compared with an ASCII-only fold. Never throws, whatever the name.

Link copied to clipboard
fun getAll(name: String): List<String>

Returns every value of name, compared with an ASCII-only fold. Never throws, whatever the name.

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code consistent with equals: it is computed from the same properties.

Link copied to clipboard

Whether there is no entry.

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

A diagnostic string for logs: the header names in order, with * after each sensitive entry, never a value. Its format is not part of the API and may change.