It seems like based on its visibility that I'm not supposed to be directly interacting with the Body of a wasmtime_wasi_http::p3::Request, but in my case I certainly would like to (which makes me think that I'm probably not doing the correct thing -- and if so would greatly appreciate learning the error of my ways!)
I have a list of event handler components which each satisfy the following interface, where each may either short-circuit and return a request/response (HandleRequestResult::Done(req_or_res)), or pass on a potentially modified request to future handlers (HandleRequestResult::Next(req)):
interface event-handler {
use wasi:http/types@0.3.0-rc-2025-09-16.{request, response};
use capabilities.{capability-provider};
variant request-or-response {
request(request),
response(response),
}
variant handle-request-result {
next(request),
done(request-or-response),
}
handle-request: func(r: request, cp: capability-provider) -> handle-request-result;
// ...other stuff unrelated to the question
}
In the case of the end result of the chain being a request (not response), from the host side I'd like to execute the resulting wasmtime_wasi_http::p3::Request, but it seems like in order to do that I'd need to have access to the request Body, or use existing wasi-http code by passing it to a simple proxy handler component which just performs the request (though this seems a bit unusual).
Does this sound right? Is there a better/easier way of doing this?
I think you're running into a limitation of the wasmtime-wasi-http crate itself which is a bug we should fix! IMO what you want is Request::into_http akin to Response::into_http. My guess is it would probably function more-or-less the same way, so in theory shouldn't be too hard to add
Okay, I'll mess around with that and can send in a PR if it ends up being legible :grimacing:
@Alex Crichton Somewhat similar here, would there be any objection to a Response::from_http method (for passing a preexisting HTTP response to a guest)?
yeah seems reasonable to me!
Last updated: Dec 06 2025 at 06:05 UTC