News for hackers. Stuff that matters.
Re:Golang's network stack attempts to parse HTTP headers as ... by userbinator on Thursday January 21, 2021 @09:28AM (#25859121)
This is the cost of "extraneous hidden complexity", or as I like to think of it, "abstraction hides bugs". As others here have noted, it is all too tempting to use a language whose string type actually does something very fancy, and be unaware of it. Most of the time it "only" causes inefficiency.

I don't remember if the HTTP spec has it, but I clearly remember the HTML spec has some parts that explicitly say "case-insensitive in the ASCII range only" (i.e. 61-7a = 41-5a), presumably to prevent things like this from happening.

Re:Golang's network stack attempts to parse HTTP headers as ... by bzbarsky on Thursday January 21, 2021 @11:49AM (#25860949)
It's for two (well, at least two) reasons: one is to prevent things like this. The other is that in generally doing case-insensitive stuff for non-ASCII is language-dependent.

For example, in English "i" and "I" are case-insensitively equal but in Turkish they are not: "i" is case-insensitively equal to "İ" (U+0130) and "I" is case-insensitively equal to "ı" (U+0131).

So if you wanted to do full-unicode case-insensitive things you would need to decide what happens with <DİV> or <dıv> and whether it depends on the language of the page or what. Doing ASCII-only case-insensitivity sidesteps all that, while admittedly privileging English over other languages.

Re:Golang's network stack attempts to parse HTTP headers as ... by dgellow on Thursday January 21, 2021 @09:41AM (#25859268)
From what I got from the spec, HTTP headers are supposed to be ASCII or opaque bytes.