-
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
[v0.3] Make (potentially all) headers mutable #113
Comments
Another header to consider is |
The idea is that the guest can arbitrarily modify In the case of |
With the current 0.3.0-draft types would it be sufficient to say that headers are copied at the boundaries of the |
Even within a single component, if you can mutate |
Maybe the answer here is to set the content-length in the |
Yes, that's also an option, and it's one we talked about a while back, because it definitely feels cleaner. A practical consideration we found though is that there's a lot of HTTP-using code that, one way or another, we want to Just Work in the |
@lukewagner I remember that there was a good reason for this, but can you remind me why it's not an option to make headers immutable at the point where they become fundamentally so—i.e. once a request/response is actually sent and the headers are on the wire? It seems like up to that point, it's entirely fair game to change |
@tschneidereit The cool thing about the current transfer semantics of It's only before that point in time that being able to mutate headers means we have to consider all these cases (like you're enumerating) and introduce custom failures (that can only happen for |
@lukewagner thank you, that helps. I agree that the way ownership transfer currently implies immutability is very nice—but it seems like your proposal gives up on that as well. Having the semantics be "ownership transfer of a But completely aside from all these questions, it seems to me like this enforces a specific order of operations on code that isn't inherent to the domain: that in keeping |
JS simply doesn't let you set Content-Length at all and instead Content-Length is set only when it guaranteed upon construction of the Request/Response (by being a Overall, it seems like we should either make |
From this discussion on the v0.3 draft PR @lukewagner said:
To which @dicej replied:
Which points to the ability to making headers mutable so that they can changed without having to rebuild request and response objects which could not only be a bit of developer experience issue but also lead to excessive copying.
Additionally,
Content-Length
is pointed to as the reason for why headers are immutable in the first place. However, in #105, @lukewagner suggests we want to leave it to guests to set theContent-Length
header correctly.While messing with
Content-Length
header is an easy way to introduce bugs, I don't understand why we fully trust the guest to set theContent-Length
header on request/response construction, but we cannot trust the guest to not mess with theContent-Length
header inappropriately down the line?The text was updated successfully, but these errors were encountered: