The zero-size chunk with optional trailers, which ends a chunked body. False, with nothing written, when a trailer is not valid or is a field a trailer may not be (framing, Host). Appends the zero-size chunk that ends a chunked body, with no trailers. Returns true.
write_last_chunk :: (out: *[..] u8) -> bool
The zero-size chunk with optional trailers, which ends a chunked body. False, with nothing written, when a trailer is not valid or is a field a trailer may not be (framing, Host). Appends the zero-size chunk that ends a chunked body, with no trailers. Returns true.
Parameters
- out: *[..] u8
Returns
- bool
write_last_chunk :: (out: *[..] u8, trailers: [] Header_Field) -> bool
Appends the zero-size chunk that ends a chunked body, followed by trailers. Returns false and writes nothing when a trailer
is not a valid field, or is one a trailer may not be (Content-Length, Transfer-Encoding, Host).
Parameters
- out: *[..] u8
- trailers: [] Header_Field
Returns
- bool
out: [..] u8;
defer array_free(out);
write_chunk(*out, "ab");
trailers := Header_Field.[.{ name = "X-Checksum", value = "7" }];
assert(write_last_chunk(*out, trailers));
assert(string.{ out.count, out.data } == "2\r\nab\r\n0\r\nX-Checksum: 7\r\n\r\n");
// Framing fields cannot be trailers, and a refused call leaves the output alone.
before := out.count;
bad := Header_Field.[.{ name = "Content-Length", value = "2", id = .CONTENT_LENGTH }];
assert(!write_last_chunk(*out, bad));
assert(out.count == before);