request
Represents an HTTP Request.
resource request;F get-method
get-method: func() -> method;Get the Method for the Request.
F set-method
set-method: func(method: method) -> result<_, _>;Set the Method for the Request. Fails if the string present in a
method.other argument is not a syntactically valid method.
F get-path-with-query
get-path-with-query: func() -> option<string>;Get the combination of the HTTP Path and Query for the Request. When
none, this represents an empty Path and empty Query.
F set-path-with-query
set-path-with-query: func(path-with-query: option<string>) -> result<_, _>;Set the combination of the HTTP Path and Query for the Request. When
none, this represents an empty Path and empty Query. Fails is the
string given is not a syntactically valid path and query uri component.
F get-scheme
get-scheme: func() -> option<scheme>;Get the HTTP Related Scheme for the Request. When none, the
implementation may choose an appropriate default scheme.
F set-scheme
set-scheme: func(scheme: option<scheme>) -> result<_, _>;Set the HTTP Related Scheme for the Request. When none, the
implementation may choose an appropriate default scheme. Fails if the
string given is not a syntactically valid uri scheme.
F get-authority
get-authority: func() -> option<string>;Get the authority of the Request's target URI. A value of none may be used
with Related Schemes which do not require an authority. The HTTP and
HTTPS schemes always require an authority.
F set-authority
set-authority: func(authority: option<string>) -> result<_, _>;Set the authority of the Request's target URI. A value of none may be used
with Related Schemes which do not require an authority. The HTTP and
HTTPS schemes always require an authority. Fails if the string given is
not a syntactically valid URI authority.
F get-options
get-options: func() -> option<request-options>;Get the request-options to be associated with this request
The returned request-options resource is immutable: set-* operations
will fail if invoked.
This request-options resource is a child: it must be dropped before
the parent request is dropped, or its ownership is transferred to
another component by e.g. handler.handle.
F get-headers
get-headers: func() -> headers;Get the headers associated with the Request.
The returned headers resource is immutable: set, append, and
delete operations will fail with header-error.immutable.
F new
new: func(headers: headers, contents: option<stream<u8>>, trailers: future<result<option<trailers>, error-code>>, options: option<request-options>) -> tuple<request, future<result<_, error-code>>>;Construct a new request with a default method of GET, and
none values for path-with-query, scheme, and authority.
headers is the HTTP Headers for the Request.
contents is the optional body content stream with none
representing a zero-length content stream.
Once it is closed, trailers future must resolve to a result.
If trailers resolves to an error, underlying connection
will be closed immediately.
options is optional request-options resource to be used
if the request is sent over a network connection.
It is possible to construct, or manipulate with the accessor functions
below, a request with an invalid combination of scheme
and authority, or headers which are not permitted to be sent.
It is the obligation of the handler.handle implementation
to reject invalid constructions of request.
The returned future resolves to result of transmission of this request.
F consume-body
consume-body: func(this: request, res: future<result<_, error-code>>) -> tuple<stream<u8>, future<result<option<trailers>, error-code>>>;Get body of the Request.
Stream returned by this method represents the contents of the body. Once the stream is reported as closed, callers should await the returned future to determine whether the body was received successfully. The future will only resolve after the stream is reported as closed.
This function takes a res future as a parameter, which can be used to
communicate an error in handling of the request.
Note that function will move the request, but references to headers or
request options acquired from it previously will remain valid.