-
Notifications
You must be signed in to change notification settings - Fork 24
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
Methods needed to get owned headers out of requests and responses #102
Comments
I think this is a very good idea. IIRC, @elliottt independently made the same suggestion too. Given how immediate the use case is and how small of an addition, this seems like a good candidate for inclusion in our next minor (0.2.1) release. |
@lukewagner great! @elliottt do you already have a branch with this or should I prepare a PR? |
I don't have a branch, and my suggestion was a little less general: I was proposing we add a What do you think about making it a static method that takes an owning reference to the request/response? That way we could be sure that there's no leftover request/response resource that has weird internal state. I suppose that since |
That would work for me, but maybe you could remind me why |
The name evolved over time, and the current behavior of returning an |
In that case, maybe we should add |
Adding a new static method would be the best path forward for an |
Closes WebAssembly#102. See discussion in that issue for the motivation and design of this change.
Closes WebAssembly#102. See discussion in that issue for the motivation and design of this change.
The main case where this is currently painful is when trying to perform modifications while forwarding along an
incoming-request
as anoutgoing-request
, orincoming-response
as anoutgoing-response
. The desired workflow is something like:Currently, this fails because
headers
is a child resource ofincoming_request
where the underlying headers are immutable, so methods likeappend
anddelete
are not permitted. Invokingoutgoing-request.new
with this child resource is fine, with embedders able to clone the headers under the hood. But once it's in theoutgoing
resource it's once again only accessible via an immutable child resource.As far as I can tell, the only way to modify headers in this proxying scenario is to explicitly clone the headers:
This isn't the end of the world, but it would be nice to avoid this clone and the implicit clone performed by constructing
outgoing-request
with a child resource by offering a means to get the headers back from these types as an owned resource. Perhaps we could, similar to Rust'shttp::Request::into_parts()
method, augment theconsume
method to also return the headers (and other parts like method, authority, path, status code [for responses]) along with the body. Strawman signatures:This will remain relevant even once 0.3.0 arrives with the unification of the
incoming-
andoutgoing-
types. If the headers can still only be accessed immutably from an existing value, proxy applications wishing to perform modifications will still have to get a mutable headers resource via some means, and absent other changes that'll mean an unnecessary clone.The text was updated successfully, but these errors were encountered: