pub trait WasiHttpHooks: Send {
// Provided methods
fn send_request(
&mut self,
request: Request<HyperOutgoingBody>,
config: OutgoingRequestConfig,
) -> HttpResult<HostFutureIncomingResponse> { ... }
fn is_forbidden_header(&mut self, name: &HeaderName) -> bool { ... }
fn outgoing_body_buffer_chunks(&mut self) -> usize { ... }
fn outgoing_body_chunk_size(&mut self) -> usize { ... }
}Available on crate feature
p2 only.Expand description
A trait which provides hooks into internal WASI HTTP operations.
§Example
use wasmtime::component::ResourceTable;
use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView};
use wasmtime_wasi_http::WasiHttpCtx;
use wasmtime_wasi_http::p2::{WasiHttpView, WasiHttpCtxView};
struct MyState {
ctx: WasiCtx,
http_ctx: WasiHttpCtx,
table: ResourceTable,
}
impl WasiHttpView for MyState {
fn http(&mut self) -> WasiHttpCtxView<'_> {
WasiHttpCtxView {
ctx: &mut self.http_ctx,
table: &mut self.table,
hooks: Default::default(),
}
}
}
impl WasiView for MyState {
fn ctx(&mut self) -> WasiCtxView<'_> {
WasiCtxView { ctx: &mut self.ctx, table: &mut self.table }
}
}
impl MyState {
fn new() -> MyState {
let mut wasi = WasiCtx::builder();
wasi.arg("./foo.wasm");
wasi.arg("--help");
wasi.env("FOO", "bar");
MyState {
ctx: wasi.build(),
table: ResourceTable::new(),
http_ctx: WasiHttpCtx::new(),
}
}
}Provided Methods§
Sourcefn send_request(
&mut self,
request: Request<HyperOutgoingBody>,
config: OutgoingRequestConfig,
) -> HttpResult<HostFutureIncomingResponse>
Available on crate feature default-send-request only.
fn send_request( &mut self, request: Request<HyperOutgoingBody>, config: OutgoingRequestConfig, ) -> HttpResult<HostFutureIncomingResponse>
default-send-request only.Send an outgoing request.
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 outgoing_body_buffer_chunks(&mut self) -> usize
fn outgoing_body_buffer_chunks(&mut self) -> usize
Number of distinct write calls to the outgoing body’s output-stream that the implementation will buffer. Default: 1.
Sourcefn outgoing_body_chunk_size(&mut self) -> usize
fn outgoing_body_chunk_size(&mut self) -> usize
Maximum size allowed in a write call to the outgoing body’s output-stream. Default: 1024 * 1024.