Closed xdmiodz closed 5 years ago
For me it's ok just strip the spaces from the header name or ignore the header at all
What do other parsers do? Like http_parser, or Netty, or Golang?
Golang allows such headers without any modifications. You can see it here
https://golang.org/src/net/http/header.go, fn CanonicalHeaderKey
Hm, no, looking further, it seems headers in Golang with spaces are rejected: https://github.com/golang/go/blob/master/src/net/http/server.go#L992
Spaces have been forbidden in header names since the HTTP/1.0 RFC. I'd rather not permit them.
For anyone wondering in the future, that was the golang/go line linked by Sean: https://github.com/golang/go/blob/c5cf6624076a644906aa7ec5c91c4e01ccd375d3/src/net/http/server.go#L992
Note that Firefox will skip headers whose name is invalid but will nonetheless parse the rest of the headers and not return an error. https://searchfox.org/mozilla-central/rev/bff70a63cff89284426d82ded6469ed708ef68b7/netwerk/protocol/http/nsHttpHeaderArray.cpp#352
It might be inconsistent to have a space in header names, but some legacy systems have such. Is it possible to support them in the httparse?