Uh oh!
There was an error while loading. Please reload this page.
HTTP streaming client, and trailer support - #34
Conversation
yoshuawuyts
commented
Dec 5, 2024
Thank you for submitting this! In general, I'm a big fan of making people's lives easier, and I believe that the general thrust of what you're filing here is the right thing to do. So, yes - I believe this is reasonable! On a first pass, this is what stood out to me:
|
Do you still like calling it
Yeah, I'll work on factoring that out.
I think it'll lead to some trouble handling bodies too :-}. I need to revamp the |
Uh oh!
There was an error while loading. Please reload this page.
I was delayed a bit by starting a new job, but I've rewritten the reactor and streams abstractions in #35#37. Hopefully that makes some aspects of this a bit simpler. I also added a bunch of common code to translate between the wasi-http types and the I'd like to avoid forcing users to ever use/know about RUSTFLAGS to compile applications. We can produce a HTTP Proxy world application with an ordinary |
Since as of bytecodealliance#19, wstd is using the http crate's types for `HeaderMap`, `Method`, and `Uri`, switch it to use the http crate's types for `Request`, `Response`, and `StatusCode` too. These types have a few more features, and this change makes wstd more interoperable with code that uses the http crate. This also helps with bytecodealliance#34, as the new `Request` and `Response` types here are independent of being incoming or outgoing.
Move `IncomingBody` and related code out of the `response` module and into the `body` module, and prepare it to be used for incoming requests as well as incoming responses. This is in preparation for bytecodealliance#34.
3d0972b to
509c406CompareI've now overhauled the API here.
Here's a simple hello-world example: #[wstd::proxy]asyncfnmain(request:Request<IncomingBody>,responder:Responder) -> Finished{
responder
.respond(Response::new(b"Hello, wasi:http/proxy world!\n")).await}For more interesting examples, including a streaming body, see the examples/http_server.rs in the PR.
I've now implemented this. That said, a downside is that it's not just the export, it's also the imports, and it means that the resulting proxy components don't run in plain |
Uh oh!
There was an error while loading. Please reload this page.
54bafd3 to
dea0b98CompareUh oh!
There was an error while loading. Please reload this page.
e705d38 to
db2b1d0Compare6e0dca1 to
853da25Compare853da25 to
5aecf66Compare309be4a to
9e8f48fCompare9e8f48f to
052b115Comparesunfishcode
commented
Jan 15, 2025
With other features factored out into separate PRs that have now landed, this PR now contains a series of patches adding output-streaming client and client trailers support, and a nice example. |
052b115 to
0b2476dCompare| /// to wait for the response. | ||
| pub struct FutureIncomingResponse(WasiFutureIncomingResponse); | ||
| impl FutureIncomingResponse { |
There was a problem hiding this comment.
I think this can be https://doc.rust-lang.org/std/future/trait.IntoFuture.html ?
There was a problem hiding this comment.
I've now updated it to use impl Future.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Pat Hickey <pat@moreproductive.org>
Add a wstd API for creating proxy applications, wrapping the WASI proxy world trait and macro.
Compiling the example with
RUSTFLAGS="-Clink-arg=--wasi-adapter=proxy"produces a program that runs inwasmtime serve.Marking as a draft for now, as it's still experimental. Feedback on the approach or "is this even a reasonable idea" welcome 😄.