Stream: git-wasmtime

Topic: wasmtime / PR #15225 wasi-http: expose `http::Extensions`...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:13):

sw17ch opened PR #15225 from sw17ch:sw17ch/expose-http-extensions to bytecodealliance:main:

Add a public extensions field to the p3 Request and Response types.

This allows embedders to attach host-side data to a request or response and to retrieve it through the Resource. For example, this allows the host to stash information associated with the request or response without placing it in headers. This change does not allow the guest to observe or construct extensions. Requests and responses created by the guest start with an empty set of extensions.

My specific use case is that I need to associate metadata with a request that came in with a header, but I want to strip this header from the request before forwarding it to the guest. The guest is able to use host calls to interact with this metadata, but should not be able to observe the value directly. By putting this in the extensions, I can reach the metadata through the Resource handle rather than having to rely on something like the address of a reachable Arc that should be unique to the Request.

I had considered and rejected several alternatives:

There is a behavior change: extensions that were previously dropped when converting between http and p3 types now pass through the guest. A concrete example is that hyper's client records non-canonical HTTP/1 reason phrases as an extension. If the guest returns this response and the host forwards it through to a hyper HTTP/1 server, that server will now write that non-canonical phrase to its client.

New tests verify that extensions survive a guest forwarding a request or response unchanged, and that the reason phrase from the hyper client survives as a hyper::ext::ReasonPhrase extension.

One gap: ProxyHandler drops extensions, so users of ProxyHandler will still not be able to access extensions associated with the request. This is one-sided: the response extensions are not stripped, so a response given to a guest and returned from the guest will preserve extensions. I am happy to open up a follow-up PR to address this gap.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:13):

sw17ch removed the review request for wasmtime-wasi-reviewers from PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:13):

sw17ch requested dicej for a review on PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:13):

sw17ch requested wasmtime-wasi-reviewers for a review on PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:13):

sw17ch requested wasmtime-core-reviewers for a review on PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:14):

sw17ch edited PR #15225:

Add a public extensions field to the p3 Request and Response types.

This allows embedders to attach host-side data to a request or response and to retrieve it through the Resource. For example, this allows the host to stash information associated with the request or response without placing it in headers. This change does not allow the guest to observe or construct extensions. Requests and responses created by the guest start with an empty set of extensions.

My specific use case is that I need to associate metadata with a request that came in with a header, but I want to strip this header from the request before forwarding it to the guest. The guest is able to use host calls to interact with this metadata, but should not be able to observe the value directly. By putting this in the extensions, I can reach the metadata through the Resource handle rather than having to rely on something like the address of a reachable Arc that should be unique to the Request or `Response.

I had considered and rejected several alternatives:

There is a behavior change: extensions that were previously dropped when converting between http and p3 types now pass through the guest. A concrete example is that hyper's client records non-canonical HTTP/1 reason phrases as an extension. If the guest returns this response and the host forwards it through to a hyper HTTP/1 server, that server will now write that non-canonical phrase to its client.

New tests verify that extensions survive a guest forwarding a request or response unchanged, and that the reason phrase from the hyper client survives as a hyper::ext::ReasonPhrase extension.

One gap: ProxyHandler drops extensions, so users of ProxyHandler will still not be able to access extensions associated with the request. This is one-sided: the response extensions are not stripped, so a response given to a guest and returned from the guest will preserve extensions. I am happy to open up a follow-up PR to address this gap.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:15):

sw17ch edited PR #15225:

Add a public extensions field to the p3 Request and Response types.

This allows embedders to attach host-side data to a request or response and to retrieve it through the Resource. For example, this allows the host to stash information associated with the request or response without placing it in headers. This change does not allow the guest to observe or construct extensions. Requests and responses created by the guest start with an empty set of extensions.

My specific use case is that I need to associate metadata with a request that came in with a header, but I want to strip this header from the request before forwarding it to the guest. The guest is able to use host calls to interact with this metadata, but should not be able to observe the value directly. By putting this in the extensions, I can reach the metadata through the Resource handle rather than having to rely on something like the address of a reachable Arc that should be unique to the Request or Response.

I had considered and rejected several alternatives:

There is a behavior change: extensions that were previously dropped when converting between http and p3 types now pass through the guest. A concrete example is that hyper's client records non-canonical HTTP/1 reason phrases as an extension. If the guest returns this response and the host forwards it through to a hyper HTTP/1 server, that server will now write that non-canonical phrase to its client.

New tests verify that extensions survive a guest forwarding a request or response unchanged, and that the reason phrase from the hyper client survives as a hyper::ext::ReasonPhrase extension.

One gap: ProxyHandler drops extensions, so users of ProxyHandler will still not be able to access extensions associated with the request. This is one-sided: the response extensions are not stripped, so a response given to a guest and returned from the guest will preserve extensions. I am happy to open up a follow-up PR to address this gap.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 21:55):

:thumbs_up: pchickey submitted PR review:

This is sensible and straightforward. Lets fill the ProxyHandler gap and use the Extensions there, and exercise that as well, rather than wait for a follow-up PR.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 22:10):

sw17ch commented on PR #15225:

Closing the gap is a 3 line diff, but that doesn't include test infrastructure. There don't appear to be any existing tests for ProxyHandler, so I'm trying to figure out what to do there. Would we accept closing the gap without a demonstration that the extensions reach end to end?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 22:25):

pchickey commented on PR #15225:

Ah yeah if ProxyHandler is untested as an embedding (vs as part of wasmtime-cli) then I'll accept those trivial 3 lines without a test. If you're using ProxyHandler in your embedding and dont mind contributing some tests in a follow up, thats appreciated but not something that should block this PR.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 23:02):

sw17ch updated PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 23:03):

sw17ch commented on PR #15225:

I have pushed eb25ef942d608762775699071389a4ebf8d49ca9 which closes the gap with a small patch. I have the start of a test, but I think it's worth spending a little more time on it before including it in this work. Thank you.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 23:03):

sw17ch edited PR #15225:

Add a public extensions field to the p3 Request and Response types.

This allows embedders to attach host-side data to a request or response and to retrieve it through the Resource. For example, this allows the host to stash information associated with the request or response without placing it in headers. This change does not allow the guest to observe or construct extensions. Requests and responses created by the guest start with an empty set of extensions.

My specific use case is that I need to associate metadata with a request that came in with a header, but I want to strip this header from the request before forwarding it to the guest. The guest is able to use host calls to interact with this metadata, but should not be able to observe the value directly. By putting this in the extensions, I can reach the metadata through the Resource handle rather than having to rely on something like the address of a reachable Arc that should be unique to the Request or Response.

I had considered and rejected several alternatives:

There is a behavior change: extensions that were previously dropped when converting between http and p3 types now pass through the guest. A concrete example is that hyper's client records non-canonical HTTP/1 reason phrases as an extension. If the guest returns this response and the host forwards it through to a hyper HTTP/1 server, that server will now write that non-canonical phrase to its client.

New tests verify that extensions survive a guest forwarding a request or response unchanged, and that the reason phrase from the hyper client survives as a hyper::ext::ReasonPhrase extension.

~One gap: ProxyHandler drops extensions, so users of ProxyHandler will still not be able to access extensions associated with the request. This is one-sided: the response extensions are not stripped, so a response given to a guest and returned from the guest will preserve extensions. I am happy to open up a follow-up PR to address this gap.~

Gap closed with eb25ef942d608762775699071389a4ebf8d49ca9.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 00:46):

pchickey added PR #15225 wasi-http: expose http::Extensions on p3 Request and Response to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 00:47):

pchickey commented on PR #15225:

Thanks John, more like this always appreciated

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 01:09):

:check: pchickey merged PR #15225.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 01:09):

pchickey removed PR #15225 wasi-http: expose http::Extensions on p3 Request and Response from the merge queue


Last updated: Nov 19 2026 at 20:05 UTC