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

Parameter | Description
--- | ---
`name` | Header name.
`value` | Header value.

Returns

Updated request.

Throws

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

Example

    import klyn.net

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