mutate

Creates a new HttpHeaders instance based on this object, using a Kotlin domain-specific language (DSL) builder.

This function provides a way to modify an existing HttpHeaders instance using expressive, English-like syntax.

The current HttpHeaders is converted to a builder, and then the init lambda with HttpHeaders.Builder as its receiver is applied. This allows the lambda to invoke the methods of HttpHeaders.Builder without having to qualify them.

Example usage:

val newHeaders = oldHeaders.mutate {
add(name, value)
}

This example modifies headers by adding one more.

Return

The mutated HttpHeaders instance.

Parameters

init

Lambda function where HttpHeaders.Builder functions can be called.