Skip to content

Stop lowercasing header names#476

Merged
annevk merged 2 commits intomasterfrom
annevk/header-names
Feb 22, 2017
Merged

Stop lowercasing header names#476
annevk merged 2 commits intomasterfrom
annevk/header-names

Conversation

@annevk
Copy link
Copy Markdown
Member

@annevk annevk commented Jan 31, 2017

Instead compare header names using a byte-case-insensitive match and
lowercase them when exposed through the API.

Fixes #203 and fixes #304.

Instead compare header names using a byte-case-insensitive match and
lowercase them when exposed through the API.

Fixes #203 and fixes #304.
@annevk
Copy link
Copy Markdown
Member Author

annevk commented Jan 31, 2017

See w3c/wptserve#112 for what is blocking tests. See web-platform-tests/wpt@e94ccfe for some test sketches.

The change shouldn't affect any JavaScript API behavior. They will still expose header names as lowercase even though the case given by the developer is used on the network. (Though see whatwg/xhr#108 and whatwg/xhr#109 for discussions on that front with regards to XMLHttpRequest, which ideally is somewhat aligned.)

If we want a discussion on whether to allow case normalization for known headers to happen (Firefox and Safari do this) we should do that through a separate issue. For now I noted it in the source that this is a thing.

I would appreciate review from @youennf and @jdm.

You can view the specification with this PR applied at https://fetch.spec.whatwg.org/branch-snapshots/annevk/header-names/. Hopefully that simplifies reviewing. (Click in the title of the red blob to hide it.)

@annevk
Copy link
Copy Markdown
Member Author

annevk commented Jan 31, 2017

@mcmanus
Copy link
Copy Markdown

mcmanus commented Feb 7, 2017

http header names are case insensitive, and h2 forces them lower case. seems weird to have case sensitive comparisons in that case

@annevk
Copy link
Copy Markdown
Member Author

annevk commented Feb 7, 2017

@mcmanus the only thing this patch does is to preserve the case, as enough users of h1 complained that lowercasing header names didn't work for them (Firefox never implemented that bit of Fetch). Comparisons are done using byte case-insensitive comparison, as is called out throughout this patch. Is there a particular instance where this is done wrong?

@mcmanus
Copy link
Copy Markdown

mcmanus commented Feb 7, 2017

Its all good - I misread part of the patch

<p class="note no-backref">This reuses the casing of the <a for=header>name</a> of the
<a>header</a> already in the <a for=/>header list</a>, if any. If there are multiple matched
<a>headers</a> their <a for=header>names</a> will all be identical.
<!-- XXX Firefox and Safari adjust known header names too. -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like the simplicity that provided case-insensitive header names to the spec.
Maybe a serialization context could have stored the casing information to leave the header names case-insensitive.
But anyway, this looks good to me as the PR is taking great care of making the specific casing unobservable from JS scripts.

I would tend to write the above statements as SHOULD/MUST/MAY, something like:
All matching headers must use the same casing.
The casing of the first header already in the list should be used for all matching headers.
The user agent may use its own casing for well-known headers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that all browsers currently make it observable through getAllResponseHeaders() so we might still get stuck there one way or another.

If we are to allow the user agent to pick casing for well-known headers I think we should probably standardize that and get everyone on board. Seems like it would be best done as a new issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't getAllResponseHeaders outputting lowercase header names with the proposed PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It currently is, yes, but whatwg/xhr#109 is still unresolved and nobody implements lowercasing there.

fetch.bs Outdated
<a for=header>combined value</a> given <var>name</var> and
<var>list</var>.

<li><p>Set <var>name</var> to <var>name</var>, <a>byte-lowercased</a>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we lowercase name before sorting? Imagine headers contains "a", "B", "c" and "D" as names. names will be ["B", "D", "a", "c"] and after lowercased it will be ["b", "d", "a", "c"].

<a for="header list">does not contain</a> `<code>Accept-Language</code>`, user agents should
<a for="header list">append</a>
`<code>Accept-Language</code>`/an appropriate <a for=header>value</a>
to <var>request</var>'s <a for=request>header list</a>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should "hint_name is not in request's header list" below be fixed?

@annevk
Copy link
Copy Markdown
Member Author

annevk commented Feb 9, 2017

Thanks @yutakahirano, I believe I addressed your feedback.

@annevk
Copy link
Copy Markdown
Member Author

annevk commented Feb 13, 2017

I'm assuming the text looks okay to everyone now. I'm mainly waiting on tests and the infrastructure needed for that.

@annevk annevk merged commit 5869c43 into master Feb 22, 2017
@annevk annevk deleted the annevk/header-names branch February 22, 2017 11:01
annevk added a commit to web-platform-tests/wpt that referenced this pull request Feb 23, 2017
annevk added a commit to web-platform-tests/wpt that referenced this pull request Feb 23, 2017
@annevk
Copy link
Copy Markdown
Member Author

annevk commented Feb 23, 2017

Ended up filing https://bugs.webkit.org/show_bug.cgi?id=168768 against WebKit.

scheib pushed a commit to scheib/chromium that referenced this pull request Apr 18, 2017
Adapt to whatwg/fetch#476, which basically says a
header list should not lowercase the header names it is passed, but rather
only do that in the "sort and combine" algorithm. This means several test
expectations had to be updated because casing _will_ be preserved when a
header is set.

To accommodate the change, turn FetchHeaderList::header_list_ into an
std::multimap with a custom comparison function in order to implement the
concept of multiple headers with possibly different casing that should all
be treated as the same header and kept sorted.

Special care has been taken not to change FetchHeaderList's API unless
absolutely necessary, but simply to avoid making the diff needlessly large.

BUG=687155
R=haraken@chromium.org,tyoshino@chromium.org,yhirano@chromium.org

Review-Url: https://codereview.chromium.org/2787003002
Cr-Commit-Position: refs/heads/master@{#465214}
TimothyGu added a commit to node-fetch/node-fetch that referenced this pull request Mar 4, 2018
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
MattiasBuelens added a commit to MattiasBuelens/yetch that referenced this pull request Aug 13, 2018
fatboy0112 added a commit to fatboy0112/node-fetch that referenced this pull request Sep 22, 2023
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
eo2305 added a commit to eo2305/eo2305 that referenced this pull request May 17, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
panagisj added a commit to panagisj/rocketfue1dev4 that referenced this pull request May 20, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
lichuan886 added a commit to lichuan886/supreme that referenced this pull request May 24, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
kah109xq added a commit to kah109xq/MalteHBy that referenced this pull request May 25, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
18qu1745145 added a commit to 18qu1745145/AlmeroSteynr that referenced this pull request May 26, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
lililunii added a commit to lililunii/hxxpaulo that referenced this pull request May 30, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
NicosiaAlexander added a commit to NicosiaAlexander/osmano that referenced this pull request Jun 10, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
FaithWesn added a commit to FaithWesn/DoctorAI that referenced this pull request Jun 12, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
FaithWesn added a commit to FaithWesn/mohame that referenced this pull request Jun 12, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
HelenHile added a commit to HelenHile/ARust that referenced this pull request Jun 12, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
YeasJoanna added a commit to YeasJoanna/codenotarye that referenced this pull request Jun 14, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
JosephLon added a commit to JosephLon/dilipku that referenced this pull request Jun 14, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
FabianSili pushed a commit to FabianSili/foschmitz that referenced this pull request Jun 15, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
ConradDickens pushed a commit to ConradDickens/infrmodsk that referenced this pull request Jun 16, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
AnupamKumay added a commit to AnupamKumay/pranay that referenced this pull request Jun 16, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
Nicholaskaiqi pushed a commit to Nicholaskaiqi/somesockst that referenced this pull request Jun 17, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
BingWhit pushed a commit to BingWhit/mohamedbinizn that referenced this pull request Jul 2, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
FinleyJone pushed a commit to FinleyJone/OpenHornet that referenced this pull request Jul 13, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
924494375 added a commit to 924494375/ouzhigangw that referenced this pull request Jul 14, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
1430183714 added a commit to 1430183714/idea that referenced this pull request Jul 14, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
DrumBeatRhythm added a commit to DrumBeatRhythm/Converts that referenced this pull request Jul 26, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
MountainMuseke added a commit to MountainMuseke/mappif that referenced this pull request Aug 12, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
VisionVillage added a commit to VisionVillage/akfess that referenced this pull request Aug 15, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
DramaDeer added a commit to DramaDeer/DramaDeer that referenced this pull request Aug 21, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
antoniosgems added a commit to antoniosgems/Multilingual that referenced this pull request Oct 14, 2025
This is unfortunately impossible to test, since the Node.js HTTP library
lower-cases all incoming headers. However, this matters for outgoing
HTTP requests. See the linked issues from the linked Fetch Standard pull
request.

See: whatwg/fetch#476
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.

Optional disable setting headers keys in lowercase Headers.get/getAll/has do not byte-lowercase the name

4 participants