HTTP Headers in Rails: Hyphens, Underscores, and a terrible day
Everyone’s favorite magician, Ruby on Rails, does it again.
As it turns out, Rack modifies incoming requests’ headers and normalizes they keys. So, every time the client/proxy sends something cool like A-HEADER
, the key is modified, so some characters become underscore. Therefore in Rails code need to access A_HEADER
, and if I had known that yesterday, my day would be much more pleasant.
Also note that when headers are mapped to CGI-like variables by the Rack
server, both dashes and underscores are converted to underscores.