3 ms·
Also, header values. They're basically require implementing a custom string type to handle correctly; they're a baroque mix of characters & "opaque octets". Yo
by userbinator 6y ago
Also, header values. They're basically require implementing a custom string type to handle correctly; they're a baroque mix of characters & "opaque octets".
You are supposed to treat all of them as "opaque octets"... or something like this might happen:
https://news.ycombinator.com/item?id=25857729 https://news.ycombinator.com/item?id=25857729
- deathanatos 6y agoYou can't. At some point, you have to actually make use of the headers, and some of those uses require decoding to a string. There is some wiggle room here, such as doing things like, header_as_raw_bytes == b"chunked" which I would argue is still decoding the header: your language of choice had to encode that string into bytes in some encoding in the first place, so even though you're comparing the encoded forms, there's still a character encoding at work. But, some of the headers are case-insensitive. E.g., Content-Type, Accept, Expect, etc. That golang bug is precisely not treating the non-characters (the "opaque octets", as defined by the standard, that is, the octets that form obs-text) as if they were characters. You won't hit that bug in the safe subset, presuming you're implementing other parts of the standard correctly. (Which is… a huge assumption, given HTTP's complexity, but that's sort of the point here.)