Skip to content

feat: implement wasi:http #58

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

Merged
merged 19 commits into from
Apr 7, 2025
Merged

feat: implement wasi:http #58

merged 19 commits into from
Apr 7, 2025

Conversation

rvolosatovs
Copy link
Member

@rvolosatovs rvolosatovs commented Mar 4, 2025

Implementation of WebAssembly/wasi-http#162

With Wasmtime binary built from this PR with this patch applied: b007214 (from #60), I have the complete round trip working using components in https://github.com/rvolosatovs/p3-http-test

@rvolosatovs
Copy link
Member Author

Added Content-Length handling for outgoing requests and responses in feb9d10, unlike wasip2, we do need to attempt to transmit the request/response to catch the error due to the lack of OutgoingBody::finish.
Since there is no way to report an error on construction of request/response, instead I enforce the fact that Content-Length header set by guests is well-formed.

None of this validation is enforced on requests/responses originating in the host (default HTTP client will enforce that incoming response body is compliant with Content-Length, testing that behavior with Hyper is still TODO) - it is assumed that it is embedders responsibility to ensure that http::Requests they feed to components have well-formed Content-Length header values and their bodies respect that. More concretely, in case of Wasmtime CLI, https://docs.rs/hyper/latest/hyper/index.html is expected to handle Content-Length correctly. From what I can see, that aligns with the existing p2 impl.

cc @pchickey

@rvolosatovs rvolosatovs force-pushed the feat/http branch 3 times, most recently from b23067a to 9b2b834 Compare April 4, 2025 15:15
@rvolosatovs rvolosatovs marked this pull request as ready for review April 4, 2025 15:52
@rvolosatovs rvolosatovs added this pull request to the merge queue Apr 4, 2025
rvolosatovs and others added 18 commits April 7, 2025 13:51
Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
Dropping the `Watch` itself just decrements the reference count, which won't
actually drop the `StreamWriter` until the promise completes.  The result was
that some of the HTTP tests were hanging.  This was my mistake, sorry!

Signed-off-by: Joel Dice <[email protected]>
As discussed with @pchickey

See also
bytecodealliance/wasmtime#7538 (comment) and following discussion

Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
This should make #100 more debuggable by turning it in to an assertion failure
in `OutgoingRequestBody::poll_frame`.  It seems to be doing a zero-length read
(presumably by accident), but I haven't traced it further than that, yet.

Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
Personally, I think defaulting to `/` if no path with query is set would
be the expected behavior, but wasip2 contained tests explicitly testing
against that behavior, so I disagree and commit

Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
@rvolosatovs rvolosatovs enabled auto-merge April 7, 2025 12:01
@rvolosatovs rvolosatovs added this pull request to the merge queue Apr 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2025
@rvolosatovs rvolosatovs enabled auto-merge April 7, 2025 12:34
#105

Signed-off-by: Roman Volosatovs <[email protected]>
@rvolosatovs rvolosatovs added this pull request to the merge queue Apr 7, 2025
Merged via the queue into main with commit e510b3f Apr 7, 2025
44 checks passed
@alexcrichton alexcrichton deleted the feat/http branch April 15, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants