origin header should not be set for GET and HEAD requests
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox65 | --- | fixed |
People
(Reporter: baku, Assigned: baku)
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 1 obsolete file)
8.66 KB,
patch
|
asuth
:
review+
|
Details | Diff | Splinter Review |
Assignee | ||
Comment 1•6 years ago
|
||
Assignee | ||
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Updated•6 years ago
|
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Updated•6 years ago
|
Comment 7•6 years ago
|
||
bugherder |
Updated•6 years ago
|
Updated•6 years ago
|
Comment 8•6 years ago
|
||
Comment 9•6 years ago
|
||
I've documented this in both places:
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin
Again, I've not mentioned this in the browser-compat-data, as I thought it was minor, and would be hard to communicate in a non-confusing way.
Let me know if that's OK. Thanks!
Updated•6 years ago
|
Comment 11•6 years ago
|
||
Sorry for commenting on a closed bug, I came here following the link on MDN, and I'm wondering if the new behavior is the correct one.
Indeed, the Fetch spec says:
If the CORS flag is set, httpRequest’s method is neither
GET
norHEAD
, or httpRequest’s mode is "websocket", then appendOrigin
/the result of serializing a request origin with httpRequest, to httpRequest’s header list
To mean that reads: "if any of those 3 condition is true, set the Origin header"; hence any CORS request should have the Origin header, not just a POST/PUT/DELETE/etc. one.
This is corroborated by the note in Section 3.1 (https://fetch.spec.whatwg.org/#origin-header)
which says:
The
Origin
header is a version of theReferer
[sic] header that does not reveal a path. It is used for all HTTP fetches whose CORS flag is set as well as those where request’s method is neitherGET
norHEAD
. [...]
And furthermore Section 3.3.2
A CORS request is an HTTP request that includes an
Origin
header. It cannot be reliably identified as participating in the CORS protocol as theOrigin
header is also included for all requests whose method is neitherGET
norHEAD
.
(note the "also")
Am I reading this wrong, is the spec due for a clarification, is the documentation on MDN confusing and indeed Origin is set, or what is actually going on here?
Comment 12•6 years ago
|
||
@Giovanni I agree. First this:
If the CORS flag is set, httpRequest’s method is neither GET nor HEAD, or
httpRequest’s mode is "websocket", then append Origin/the result of
serializing a request origin with httpRequest, to httpRequest’s header list
and this:
A CORS request is an HTTP request that includes an Origin header. It cannot be
reliably identified as participating in the CORS protocol as the Origin header
is also included for all requests whose method is neither GET nor HEAD.
these are vague, and frankly flat wrong. When a request is made via fetch
, the
Origin
header should always be sent, else how will the receiver be able to
block it? If the origin doesnt match the destination, then its a CORS
request. Both these paragraphs make it sound like a CORS request is something
the sender gets to choose. They dont. Any conforming browser should be
sending this header without exception else CORS doesnt mean anything anymore.
This seems pretty blatant and im not sure how this patch got through.
Comment 14•6 years ago
|
||
Discussion about the spec issue is now happening on https://github.com/whatwg/fetch/issues/871
Updated•6 years ago
|
Description
•