Headers

class Headers

Library-owned, immutable collection of HTTP header name/value pairs.

Unlike a plain Map, Headers preserves both duplicate names and the original insertion order, while still supporting case-insensitive lookup (HTTP header names are case-insensitive). Build instances via the companion object factories or the nested Builder.

Types

Link copied to clipboard
class Builder

Mutable builder that accumulates header pairs and produces a Headers.

Link copied to clipboard
object Companion

Factories for creating Headers.

Properties

Link copied to clipboard
val size: Int

The total number of name/value pairs, counting duplicate names.

Functions

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

Value equality over the ordered list of name/value pairs.

Link copied to clipboard
fun forEach(action: (name: String, value: String) -> Unit)

Invokes action for each header name/value pair, in insertion order.

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

Returns the value of the first header whose name matches name case-insensitively, or null if there is no such header.

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

Returns every value whose header name matches name case-insensitively, in insertion order. Returns an empty list when there is no match.

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

Hash code consistent with equals.

Link copied to clipboard

Returns true when there are no headers.

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

Returns all header names in insertion order; names may repeat.

Link copied to clipboard

Returns an ordered copy of the header pairs.

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

Human-readable rendering of the header pairs.