Appends a request head, framing included, and returns how the body must be sent: with a
non-negative body_length, Content-Length is added (except for a GET, HEAD, DELETE, CONNECT or
TRACE without a body) and the body is sent as is (.LENGTH, or .NONE for length 0); with -1 the
length is not known, Transfer-Encoding: chunked is added and the body goes through
write_chunk and write_last_chunk (.CHUNKED). ok is false, and out is left as it was,
when a header is not valid or sets the framing itself.
- out: the buffer the head is appended to.
- method: the request method, such as
"GET". - target: the request target: the path and query, such as
"/users?page=2". - headers: sent as given. Framing headers (
Content-Length,Transfer-Encoding) are added for you, so passing one is an error. - body_length: the body size in bytes, 0 for none, or -1 when it is not known yet.
write_request_head :: (
out: *[..] u8,
method: string,
target: string,
headers: [] Header_Field,
body_length: s64
) -> (Body_Kind, bool)
Appends a request head, framing included, and returns how the body must be sent: with a
non-negative body_length, Content-Length is added (except for a GET, HEAD, DELETE, CONNECT or
TRACE without a body) and the body is sent as is (.LENGTH, or .NONE for length 0); with -1 the
length is not known, Transfer-Encoding: chunked is added and the body goes through
write_chunk and write_last_chunk (.CHUNKED). ok is false, and out is left as it was,
when a header is not valid or sets the framing itself.
Parameters
- out: *[..] u8
- the buffer the head is appended to.
- method: string
- the request method, such as
"GET". - target: string
- the request target: the path and query, such as
"/users?page=2". - headers: [] Header_Field
- sent as given. Framing headers (
Content-Length,Transfer-Encoding) are added for you, so passing one is an error. - body_length: s64
- the body size in bytes, 0 for none, or -1 when it is not known yet.
Returns
- bool