Skip to content
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

strip request-body-header for redireting from POST to GET #977

Merged
merged 6 commits into from Dec 11, 2019

Conversation

JuniorHsu
Copy link
Contributor

@JuniorHsu JuniorHsu commented Dec 3, 2019

@JuniorHsu
Copy link
Contributor Author

This addresses #609. I'll work on test and gecko implementation.
@annevk does the patch make sense?

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me, modulo nits. Thanks for working on this!

@ricea do you have any further feedback? Should someone else from Chrome be consulted?

@youennf I'm not sure if WebKit does this at the moment, but your review would be appreciated. And we'll file a bug if there are any tests you might fail.

fetch.bs Outdated
<ol class=brief>
<li><p> Set <var>request</var>'s <a for=request>method</a> to `<code>GET</code>` and
<var>request</var>'s <a for=request>body</a> to null.
<li><p> <p><a for="list">For each</a> <var>headerName</var> of
Copy link
Member

Choose a reason for hiding this comment

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

There's a markup error here.

fetch.bs Outdated
<p>then:

<ol class=brief>
<li><p> Set <var>request</var>'s <a for=request>method</a> to `<code>GET</code>` and
Copy link
Member

Choose a reason for hiding this comment

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

No need for the space before "Set".

@annevk
Copy link
Member

annevk commented Dec 3, 2019

#944 is a bit related to this, if you wanted to pick up more issues in this space.

@ricea
Copy link
Collaborator

ricea commented Dec 4, 2019

lgtm. It would be nice if there were tests, but I guess whichever browser implements this first will write them. CC: @yutakahirano who was also active on https://bugs.chromium.org/p/chromium/issues/detail?id=765898.

@annevk
Copy link
Member

annevk commented Dec 4, 2019

@davidben are you on board with stripping more headers than Content-Type and Content-Length?

@davidben
Copy link
Collaborator

davidben commented Dec 4, 2019

I like how in 2019, we still don't know what HTTP redirects are. :-)

This is a list of request headers to remove, right? This list is strange. Content-Disposition, Content-Range, and ETag are defined as response headers.

Adding @MattMenke2 and @mnot who may have thoughts about this. One hopes the risk of changes here is tiny, but we should incur that risk at most once.

@MattMenke2
Copy link
Contributor

There's also Transfer-Encoding (No idea if Transfer-Encoding is generally used in place of Content-Encoding for uploads, but if we're encouraging using these sorts of entity-body headers symmetrically for request and response bodies, seems like it should be here).

Does seem like we should create some more formal grouping of entity-body headers that can apply both to uploads and downloads, if we want to have some sort of support for consumers setting them in web-platform uploads.

@davidben
Copy link
Collaborator

davidben commented Dec 4, 2019

Can Transfer-Encoding be set by web content? I would hope not since it's a property of how the browser arranges bytes on the wire, rather than the request itself. In that case, hopefully it gets applied below redirect handling anyway.

@MattMenke2
Copy link
Contributor

The same is true of Content-Encoding, no? I mean, they're nominally different, but in practice, not so much. Regardless, there's discussion of a streaming upload API, which would use chunked uploads. No idea if Chrome's pre-existing chunked upload support uses.

@annevk
Copy link
Member

annevk commented Dec 4, 2019

Transfer-Encoding is blocked, Content-Encoding is not, see https://fetch.spec.whatwg.org/#forbidden-header-name.

@MattMenke2
Copy link
Contributor

But we still have rules for how forbidden headers are mutated as we follow redirects. Also, I don't think any browser should be letting web content set "Content-Encoding: chunked" directly.

@MattMenke2
Copy link
Contributor

Though I suppose chunked is generally advertised as a Transfer-Encoding, it just seems not a great idea.

@davidben
Copy link
Collaborator

davidben commented Dec 4, 2019

I don't think Content-Encoding: chunked means anything, so it shouldn't be any different from Content-Encoding: garbage. While Transfer-Encoding nominally can also do compression, I don't think any browser supports it.

The two are effectively orthogonal. Content-Encoding is whether there is compression applied to the body and should be supplied by whoever supplied the body. Transfer-Encoding is largely a symptom of HTTP/1.1's poor layering. It should be supplied by the low-level HTTP/1.1 (and not HTTP/2) encoding logic, well below Fetch and the web platform. Alas, HTTP headers are a leaky abstraction, so we're stuck needling to forbid Transfer-Encoding at the Fetch level, but we should layer things so we otherwise don't need to think about it.

@MattMenke2
Copy link
Contributor

I do think that consumers have just as much control over Transfer-Encoding: chunked (Assuming we expose a streaming upload API) as they have over Content-Length. Neither one can they set directly, but they can set them indirectly (By their selection of upload body or their choice of upload API).

fetch.bs Outdated Show resolved Hide resolved
@JuniorHsu
Copy link
Contributor Author

We're wondering if we need to remove request-body-header (Content-Type, Content-Language... ) from request headers for GET->GET redirection if the client adds them, e.g, fetch(url, {headers: {"Content-Encoding": "Identity"}} for a 301/302/303 response.

We suspect that leaving GET->GET alone is probably the quickest way to consensus, and I'd like to include GET->GET in the web-platform tests.

@annevk
Copy link
Member

annevk commented Dec 9, 2019

@JuniorHsu if we want to leave GET -> GET alone we do have to add a check for 303 in the specification: that method is not GET or HEAD. As the current wording does affect GET -> GET for 303s.

@JuniorHsu
Copy link
Contributor Author

@JuniorHsu if we want to leave GET -> GET alone we do have to add a check for 303 in the specification: that method is not GET or HEAD. As the current wording does affect GET -> GET for 303s.

Thanks for finding this. It's good to be consistent

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great. Also thanks all for the comments. If there are no further issues here I plan to merge this before the end of the week and @JuniorHsu or I will ensure browser bugs as a result of failing tests are filed as well.

@JuniorHsu
Copy link
Contributor Author

@annevk
Copy link
Member

annevk commented Dec 11, 2019

annevk pushed a commit to web-platform-tests/wpt that referenced this pull request Dec 11, 2019
@annevk annevk merged commit 20ec6d0 into whatwg:master Dec 11, 2019
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 16, 2019
…headers for redirects, a=testonly

Automatic update from web-platform-tests
Fetch: delete request-body-headers for certain redirects

For whatwg/fetch#977.
--

wpt-commits: d09c77af120af9c9db2065378186f7942e2f157f
wpt-pr: 20596
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 17, 2019
…headers for redirects, a=testonly

Automatic update from web-platform-tests
Fetch: delete request-body-headers for certain redirects

For whatwg/fetch#977.
--

wpt-commits: d09c77af120af9c9db2065378186f7942e2f157f
wpt-pr: 20596

UltraBlame original commit: 9371ed11e8f6975180647ac24191d302972613b5
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 17, 2019
…headers for redirects, a=testonly

Automatic update from web-platform-tests
Fetch: delete request-body-headers for certain redirects

For whatwg/fetch#977.
--

wpt-commits: d09c77af120af9c9db2065378186f7942e2f157f
wpt-pr: 20596

UltraBlame original commit: 9371ed11e8f6975180647ac24191d302972613b5
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 17, 2019
…headers for redirects, a=testonly

Automatic update from web-platform-tests
Fetch: delete request-body-headers for certain redirects

For whatwg/fetch#977.
--

wpt-commits: d09c77af120af9c9db2065378186f7942e2f157f
wpt-pr: 20596

UltraBlame original commit: 9371ed11e8f6975180647ac24191d302972613b5
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Dec 17, 2019
…headers for redirects, a=testonly

Automatic update from web-platform-tests
Fetch: delete request-body-headers for certain redirects

For whatwg/fetch#977.
--

wpt-commits: d09c77af120af9c9db2065378186f7942e2f157f
wpt-pr: 20596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants