pub trait WasiHttpCtx: Send {
// Provided methods
fn is_forbidden_header(&mut self, name: &HeaderName) -> bool { ... }
fn is_supported_scheme(&mut self, scheme: &Scheme) -> bool { ... }
fn set_host_header(&mut self) -> bool { ... }
fn default_scheme(&mut self) -> Option<Scheme> { ... }
fn send_request(
&mut self,
request: Request<BoxBody<Bytes, ErrorCode>>,
options: Option<RequestOptions>,
fut: Box<dyn Future<Output = Result<(), ErrorCode>> + Send>,
) -> Box<dyn Future<Output = Result<(Response<BoxBody<Bytes, ErrorCode>>, Box<dyn Future<Output = Result<(), ErrorCode>> + Send>), TrappableError<ErrorCode>>> + Send> { ... }
}
p3
only.Expand description
A trait which provides internal WASI HTTP state.
Provided Methods§
Sourcefn is_forbidden_header(&mut self, name: &HeaderName) -> bool
fn is_forbidden_header(&mut self, name: &HeaderName) -> bool
Whether a given header should be considered forbidden and not allowed.
Sourcefn is_supported_scheme(&mut self, scheme: &Scheme) -> bool
fn is_supported_scheme(&mut self, scheme: &Scheme) -> bool
Whether a given scheme should be considered supported.
handle
will return ErrorCode::HttpProtocolError for unsupported schemes.
Sourcefn set_host_header(&mut self) -> bool
fn set_host_header(&mut self) -> bool
Whether to set host
header in the request passed to send_request
.
Sourcefn default_scheme(&mut self) -> Option<Scheme>
fn default_scheme(&mut self) -> Option<Scheme>
Scheme to default to, when not set by the guest.
If None, handle
will return ErrorCode::HttpProtocolError
for requests missing a scheme.
Sourcefn send_request(
&mut self,
request: Request<BoxBody<Bytes, ErrorCode>>,
options: Option<RequestOptions>,
fut: Box<dyn Future<Output = Result<(), ErrorCode>> + Send>,
) -> Box<dyn Future<Output = Result<(Response<BoxBody<Bytes, ErrorCode>>, Box<dyn Future<Output = Result<(), ErrorCode>> + Send>), TrappableError<ErrorCode>>> + Send>
Available on crate feature default-send-request
only.
fn send_request( &mut self, request: Request<BoxBody<Bytes, ErrorCode>>, options: Option<RequestOptions>, fut: Box<dyn Future<Output = Result<(), ErrorCode>> + Send>, ) -> Box<dyn Future<Output = Result<(Response<BoxBody<Bytes, ErrorCode>>, Box<dyn Future<Output = Result<(), ErrorCode>> + Send>), TrappableError<ErrorCode>>> + Send>
default-send-request
only.Send an outgoing request.
This function will be used by the wasi:http/handler#handle
implementation.
The specified Future fut
will be used to communicate
a response processing error, if any.
For example, if the response body is consumed via wasi:http/types.response#consume-body
,
a result will be sent on fut
.
The returned Future can be used to communicate
a request processing error, if any, to the constructor of the request.
For example, if the request was constructed via wasi:http/types.request#new
,
a result resolved from it will be forwarded to the guest on the future handle returned.
Content-Length
of the request passed to this function will be validated, however no
Content-Length
validation will be performed for the received response.
Implementors§
impl WasiHttpCtx for DefaultWasiHttpCtx
default-send-request
only.