-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add guest binding for wasi-http #69
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 |
crates/wasi-http/src/lib.rs
Outdated
http::Method::CONNECT => http_types::Method::Connect, | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the wit-bindgen v0.4, i don't have the FromStr
nor the http_types::Method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am planning on updating those dependencies when we have the next major bump in wasmtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i implemented the tryfrom and returned an error instead of panicing
crates/wasi-http/src/lib.rs
Outdated
@@ -95,29 +95,29 @@ impl TryFrom<http::Request<Bytes>> for Request { | |||
} | |||
} | |||
|
|||
pub struct Method<'a>(http_types::MethodParam<'a>); | |||
pub struct Method(http_types::Method); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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