-
Notifications
You must be signed in to change notification settings - Fork 356
Description
When the accept header is larger than 128 bytes, the request will trigger a preflight request that blocks if the accept header is not explicitly set. This length looks quite arbitrary: is there a reason for this? But even when the preflight request happens, probably the accept header should not explicitly be set?
The length breaks use cases where a browser script is used to query different web resources on the fly.
Asking all open web resource servers to set the Access-Control-Allow-Headers: accept
in order to circumvent this seems like much to ask for no real added security?
Reproducing in Chromium
// Test 1: works
fetch('https://graph.irail.be/sncb/connections?departureTime=2019-01-27',
{
headers: new Headers({
accept: "application/ld+json"
})
}).then(async (response)=> { console.log(await response.json())});
// Test 2: fails
fetch('https://graph.irail.be/sncb/connections?departureTime=2019-01-27',
{
headers: new Headers({
accept: "application/trig;q=1.0,application/n-quads;q=0.7,text/turtle;q=0.6,application/n-triples;q=0.3,application/ld+json;q=0.3,text/n3;q=0.2"
})
}).then(async (response)=> { console.log(await response.json())});
In other browsers
Mozilla docs have this to say:
Note that certain headers are always allowed: Accept, Accept-Language, Content-Language,
Content-Type (but only with a MIME type of its parsed value (ignoring parameters) of either
application/x-www-form-urlencoded, multipart/form-data, or text/plain). These are called the simple
headers, and you don't need to specify them explicitly.
Src: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers#Directives
The test cases do work in Firefox.
In the whatwg spec
- https://fetch.spec.whatwg.org/#cors-unsafe-request-header-names – Indicates the 1024 size problem
- https://fetch.spec.whatwg.org/#no-cors-safelisted-request-header-name – Indicates that the Accept header is safelisted
Question: is this a chromium specific bug, or is this unclear in the whatwg specification and should this be corrected?
Context
We are working on querying open web resources. Setting a long Accept header is therefore quite normal: we can parse a lot of different formats.
Related issue: comunica/comunica#373