response
An HTTP response.
resource response;F get-header-names
get-header-names: func(max-len: u64, cursor: u32) -> result<tuple<string, option<u32>>, error>;Read the response's header names via a buffer of the provided size.
The first cursor names are skipped. The remaining names are encoded successively with
a NUL byte after each into a list of bytes at most max-len long. If any of the remaining
names don't fit, the returned option<u32> is the index of the first name that didn't fit,
or none if all the remaining names fit. If max-len is too small to fit any name,
an error.buffer-len error is returned, providing a recommended buffer size.
F get-header-value
get-header-value: func(name: string, max-len: u64) -> result<option<list<u8>>, error>;Gets the value of a header, or none if the header is not present.
If there are multiple values for the header, only one is returned. See
get-header-values if you need to get all of the values.
If header name requires more than max-len bytes, this will return an error.buffer-len
containing the required size.
F get-header-values
get-header-values: func(name: string, max-len: u64, cursor: u32) -> result<tuple<list<u8>, option<u32>>, error>;Gets multiple header values for the given name via a buffer of the provided size.
As opposed to get-header-value, this function returns all of the values for this header.
The first cursor values are skipped. The remaining values are encoded successively with
a NUL byte after each into a list of bytes at most max-len long. If any of the remaining
values don't fit, the returned option<u32> is the index of the first value that didn't
fit, or none if all the remaining values fit. If max-len is too small to fit any value,
an error.buffer-len error is returned, providing a recommended buffer size.
F set-header-values
set-header-values: func(name: string, values: list<u8>) -> result<_, error>;Sets the values for the given header name, replacing any headers that previously existed for that name.
F insert-header
insert-header: func(name: string, value: list<u8>) -> result<_, error>;Sets a response header to the given value, discarding any previous values for the given header name.
F append-header
append-header: func(name: string, value: list<u8>) -> result<_, error>;Add a response header with given value.
Unlike set-header-values, this does not discard existing values for the same header name.
F remove-header
remove-header: func(name: string) -> result<_, error>;Remove all response headers of the given name
Returns ok if any headers were successfully removed.
F get-version
get-version: func() -> result<http-version, error>;Gets the HTTP version of this response.
F set-version
set-version: func(version: http-version) -> result<_, error>;Sets the HTTP version of this response.
F get-status
get-status: func() -> result<http-status, error>;Gets the HTTP status code of the response.
F set-status
set-status: func(status: http-status) -> result<_, error>;Sets the HTTP status code of the response.
F set-framing-headers-mode
set-framing-headers-mode: func(mode: framing-headers-mode) -> result<_, error>;Sets how the framing headers Content-Length and Transfer-Encoding will be determined
when sending this response.
F set-http-keepalive-mode
set-http-keepalive-mode: func(mode: keepalive-mode) -> result<_, error>;Adjust the response's connection reuse mode.
F get-remote-ip-addr
get-remote-ip-addr: func() -> option<ip-address>;Gets the destination IP address used for this response, if known.
F get-remote-port
get-remote-port: func() -> option<u16>;Gets the destination port used for this response, if known.
F new
Create a new response.
The new response is created with status code 200 OK, no headers, and an empty body.