Skip to content

HttpHeaders

1 min read

Import: import system.net;

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

HttpHeaders

Case-insensitive header names with ordered repeated values. Validation occurs when sending.

public class HttpHeaders

constructor

Creates an empty header collection.

public constructor()

length

Number of stored header pairs, including repeated names.

public get length(): int

append

Appends a value without replacing existing values for the same name.

public fun append(name: string, value: string): void

set

Replaces all existing values for name with one value at the end of the collection.

public fun set(name: string, value: string): void

get

Returns the first matching value, or None when absent.

public fun get(name: string): Option<string>

get_all

Copies every matching value in stored order; JS Fetch may already have combined repeated headers.

public fun get_all(name: string): string[]

remove

Removes all values with the given case-insensitive name.

public fun remove(name: string): void

to_json

Serializes header pairs in order, preserving repeated names.

public fun to_json(): JsonValue