123module juptune.http.v1;
alias putHeader = ;
Writes a single header.
The writer must be in the headersstate.
The writer will be in the headersstate after this function is called.
If the header is "content-length" then the writer will enter an internal state that allows it to keep track of how much data has been written with putBody.
If the header is "transfer-encoding" with a value of "chunked" then the writer will enter an internal state that allows it to create chunked bodies when using putBody.
The writer will automatically keep track of any critical headers it requires in order to function correctly, such as "content-length" and "transfer-encoding".
In defiance of the RFC, and is relatively common practice nowadays, the writer will force all header names into lowercase. This is to simplify the user code's processing, and to ensure the user code does not have to deal with case-insensitive comparisons.
This is especially important for user code that can use HTTP/2 and HTTP/3, as those protocols are case-insensitive with header names. (if/whenever these protocols are supported). Case-sensitive header names are a relic of the past, and should not be used nor encouraged.
Headers are written in the order they are provided.
If an error occurs, the writer will be in an invalid state and should not be used again.
Anything the underlying I/O functions can throw. See juptune.event.io.IoError.
Http1Error.badHeaderNameif the header name is invalid.
Http1Error.badHeaderValueif the header value is invalid.
Http1Error.badTransportif putTraileris being used when not using chunked encoding.
A Resultdescribing if an error ocurred. Any Http1Errorwill contain a valid HTTP error response.