T29: use QuickJS and verify the HTTP hook and guest networking
This commit is contained in:
@@ -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,
|
||||
> {
|
||||
|
||||
Reference in New Issue
Block a user