Skip to content

add response-outparam.send-informational #139

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 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
./wit-deps lock --check
- uses: WebAssembly/wit-abi-up-to-date@v22
with:
wasm-tools: '1.218.0'
wit-bindgen: '0.33.0'
wasm-tools: '1.223.0'
wit-bindgen: '0.37.0'
worlds: 'imports proxy'
15 changes: 15 additions & 0 deletions wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,21 @@ interface types {
/// other argument to `incoming-handler.handle`.
@since(version = 0.2.0)
resource response-outparam {
/// Send an HTTP 1xx response.
///
/// Unlike `response-outparam.set`, this does not consume the
/// `response-outparam`, allowing the guest to send an arbitrary number of
/// informational responses before sending the final response using
/// `response-outparam.set`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit late, but does this also allow sending 101 Switching Protocols which indicates that the following data will be for a non-http protocol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it myself, but I think that should work even without response-outparam.send-informational. IIUC, a 101 only requires sending a single HTTP-level response (unlike 103, which involves sending more than one), so presumably you could use response-outparam.set to send a 101, then treat the request input-stream and response output-stream as a full-duplex connection over which the agreed-upon protocol may proceed.

Whether that works today with e.g. wasmtime-wasi-http is another question -- probably not, but I don't see any obstacle at the WIT interface level to making it work.

///
/// This will return an `HTTP-protocol-error` if `status` is not in the
/// range [100-199], or an `internal-error` if the implementation does not
/// support informational responses.
@unstable(feature = informational-outbound-responses)
send-informational: func(
status: u16,
headers: headers
) -> result<_, error-code>;

/// Set the value of the `response-outparam` to either send a response,
/// or indicate an error.
Expand Down
Loading