XMLHttpRequest's setRequestHeader() gets undefined trimming |
|||||||
Issue description
In Chrome, if you do
setRequestHeader("x", "x");
setRequestHeader("x", "");
the resulting value is "x," instead of "x, " (note the trailing space). Arguably per HTTP these are identical, but no other browser does this and I'm not sure it makes sense to perform another trimming operation (we already perform one on the value given to the method invocation) if this is the input from the web developer.
https://github.com/web-platform-tests/wpt/pull/13471 has a test for this (still needs review).
,
Oct 22
I can also reproduce with fetch:
fetch('/fgftgrft', { mode: 'same-origin', headers: { x: 'x', 'X': '' } });
So I don't think it's happening in the XHR code.
,
Oct 22
,
Oct 22
I'm a lil busy this week, but it somewhat makes sense to me to have everyone change to Chrome's behavior here, if H2 and QUIC guarantee no trailing space. That would give a consistent HTTP semantic across versions and also give a consistent story to service workers. So maybe we should make Fetch strip trailing spaces before doing a request, unless there's an easier fix.
,
Oct 22
So would that be never a space after an added comma "Foo: ,bar,,", or only at the end ("Foo: , bar, ,")? Regardless, looking at the H2 spec, I can find no mention of restrictions on what can or cannot appear in the header value field (It's possible I'm missing something. It's also possible it just defers to HTTP/1.x).
,
Oct 22
I was thinking only at the end, hence deferring the trimming to early on in the fetch (which also means the space would be visible in the Headers object where you created it). It's not exactly great, but it's also the only way to get a trailing space which maybe isn't warranted...
,
Nov 7
,
Nov 7
Sorry, I overlooked #2...
,
Nov 8
external/wpt/xhr/setrequestheader-combining.window.js is the test for this issue.
,
Nov 8
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by mmenke@chromium.org
, Oct 19