klyn.net.HttpRequest.withHeader
method

    public withHeader(name as String, value as String) as HttpRequest throws Exception:

Description

Returns a copy with one header added or replaced.

Parameters

- name Header name.
- value Header value.

Returns

Updated request. ```klyn import klyn.net request = HttpRequest("https://example.com").withHeader("Accept", "application/json") print(request.headers.size)` ``

Throws

- Exception if request validation, serialization, network transport, TLS handling, or response creation fails.