Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Aliases Http1ReaderBase.readHeader

1
2
3
module juptune.http.v1;

alias readHeader = ;

Documentation

Reads a single header.

State

This function must be called when the reader is in the headersstate.

After this function is called, the reader will be in the maybeEndOfHeadersstate.

If the header is "content-length" then the reader will enter an internal state that allows it to keep track of how much data has been read from the body when using readBody.

If the header is "transfer-encoding" with a value of "chunked" then the reader will enter an internal state that allows it to parse the chunked body when using readBody.

Notes

Certain headers that are critical to the reader's operation will be processed automatically, but will still be returned to the user code for custom processing.

In defiance of the RFC, and is relatively common practice nowadays, the reader 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.

In case it's not clear, headers are always returned in the order they were sent by the client.

Params

Throws

If an error occurs, the reader 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.dataExceedsBufferif the entire header line is larger than the provided buffer.

Http1Error.badHeaderNameif the header name is missing or invalid.

Http1Error.badHeaderValueif the header value is missing or invalid.

Http1Error.badLengthHeaderif the header is a content-length or transfer-encoding header when another header of the same type has already been read.

Http1Error.badLengthHeaderif the header is a content-length header and the value is not a valid size_t.

Http1Error.badTransportif it is determined that the transport layer is in a bad state, or if the sender appears to be malicious/poorly coded.

Returns

A Resultdescribing if an error ocurred. Any Http1Errorwill contain a valid HTTP error response that can be sent to the client as-is.