T29: use QuickJS and verify the HTTP hook and guest networking

This commit is contained in:
2026-11-06 23:38:21 +00:00
parent 7c7656c4a8
commit bb162abd4d
6 changed files with 86 additions and 48 deletions
+10 -6
View File
@@ -37,7 +37,9 @@ fn response(response: Response<Bytes>) -> (Response<WasiBody>, Io) {
}
impl WasiHttpHooks for Hooks {
// Admit every scheme until the URI supplies the host name.
fn is_supported_scheme(&mut self, _: &http::uri::Scheme) -> bool { true }
fn is_supported_scheme(&mut self, _: &http::uri::Scheme) -> bool {
true
}
fn send_request(
&mut self,
request: Request<WasiBody>,
@@ -61,7 +63,9 @@ impl WasiHttpHooks for Hooks {
return Ok(response(router(&caller, Request::from_parts(parts, bytes))));
}
if !matches!(parts.uri.scheme_str(), Some("http" | "https")) {
while let Some(frame) = body.frame().await { frame?; }
while let Some(frame) = body.frame().await {
frame?;
}
return Err(Error::HttpRequestUriInvalid);
}
let result =
@@ -144,14 +148,14 @@ impl<T> TokioStream for T where T: AsyncRead + AsyncWrite + Send + Sync + Unpin
/// Preserve Wasmtime's HTTP/1 transport and request deadlines, but connect only to checked addresses.
/// The returned future drives the connection after the response headers arrive.
async fn send_request(
mut req: Request<impl Body<Data = Bytes, Error = Error> + Send + 'static>,
async fn send_request<T: Body<Data = Bytes, Error = Error> + Send + 'static>(
mut req: Request<T>,
options: Option<RequestOptions>,
policy: &super::net::NetPolicy,
) -> Result<
(
Response<impl Body<Data = Bytes, Error = Error>>,
impl Future<Output = Result<(), Error>> + Send,
Response<impl Body<Data = Bytes, Error = Error> + use<T>>,
impl Future<Output = Result<(), Error>> + Send + use<T>,
),
Error,
> {