feat: add guest binding for wasi-http#69
Conversation
We are migrating the code from here: https://github.com/bytecodealliance/preview2-prototyping/blob/47b30fdad11553841bbee4c5632101bbd645854b/wasi/src/http.rs And based on the example from the wasmtime repository: https://github.com/bytecodealliance/wasmtime/blob/362696a2d363d583887a726d979944d221eb5b4b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs
|
Hey, sorry, this one just popped up on my feed despite it being here for a little while. I haven't yet figured out a plan for how we are upstreaming the p2-p stuff into this crate. I suppose, for Upstreaming the functionality that currently lives in the @alexcrichton do you have any objections to creating this new |
| http::Method::TRACE => http_types::Method::Trace, | ||
| http::Method::HEAD => http_types::Method::Head, | ||
| http::Method::OPTIONS => http_types::Method::Options, | ||
| _ => panic!("failed due to unsupported method, currently supported methods are: GET, POST, PUT, DELETE, PATCH, CONNECT, TRACE, HEAD, and OPTIONS"), |
There was a problem hiding this comment.
http_types::Method has a FromStr method we could use to try parsing the http::Method. I don't think we should have panics in here, and instead use TryFrom.
There was a problem hiding this comment.
with the wit-bindgen v0.4, i don't have the FromStr nor the http_types::Method
There was a problem hiding this comment.
i am planning on updating those dependencies when we have the next major bump in wasmtime
There was a problem hiding this comment.
i implemented the tryfrom and returned an error instead of panicing
| } | ||
|
|
||
| pub struct Method<'a>(http_types::MethodParam<'a>); | ||
| pub struct Method(http_types::Method); |
There was a problem hiding this comment.
Do we need to make a new type that Derefs to Method? Instead, we could just impl TryFrom<http::Method> for http_types::Method, and not create a new type at all.
There was a problem hiding this comment.
i am assuming that the preview2 interfaces will be imported from the crate wasi
40370b1 to
a891778
Compare
|
I finally got another PR working by using the guest binding from here, so the moment we have a new version published I can move forward. |
|
This all seems useful to have somewhere for sure, but I feel that this is pretty significantly diverging from what the Given the precedence of There's also sort of the question of "are things ready yet" which I don't know how best to answer. This crate is relatively stable/official for preview1 but preview2 and its related support/etc aren't quite at that same level yet. I don't know how best to bridge that gap. One route is something like this where it's largley "just land it and let everyone deal with breakage later", but there's also the possibility of doing something more nuanced/measured where this is fit into a larger plan of rolling out preview2, evalutating it, etc. Or perhaps such a plan already exists and I'm not aware, unsure! |
4b3b5f0 to
8d5d6a8
Compare
|
@alexcrichton , I pushed some changes as per your suggestion by exposing the HTTP related interfaces (those would probably make more sense the I believe the |
|
In DM and in bytecodealliance/preview2-prototyping#157 Eduardo and I discussed that we don't really have a great way to land preview 2 stuff in the |
We are migrating the code from here that is implementing a basic HTTP client on top of the generated binding: https://github.com/bytecodealliance/preview2-prototyping/blob/47b30fdad11553841bbee4c5632101bbd645854b/wasi/src/http.rs
And based on the example from the wasmtime repository: https://github.com/bytecodealliance/wasmtime/blob/362696a2d363d583887a726d979944d221eb5b4b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs