with

open fun with(key: String, value: String): Header

Adds a key-value pair to this header and returns the header for method chaining.

This method provides a fluent API for setting header values, allowing multiple header modifications to be chained together. Internally, this delegates to the put method, which will check the read-only status before making changes.

Return

This header instance to support method chaining

Parameters

key

The header key to set (must not be null or empty)

value

The header value to associate with the key (must not be null)

Throws

if the header is read-only

Samples


open fun with(additional: Map<String, String>): Header

Adds all key-value pairs from the provided map to this header and returns the header for method chaining.

This method provides a fluent API for bulk header modifications, allowing multiple header fields to be set at once. Internally, this delegates to the putAll method, which will check the read-only status before making changes.

Return

This header instance to support method chaining

Parameters

additional

A map containing key-value pairs to add to this header (must not be null)

Throws

if the header is read-only

Samples