I am trying to get request headers in their original format from Rack using Ruby, but have not figured it out yet. Hash, I come back with a request. I do not want it. In this hash, the header keys are at the top and have underscores instead of dashes, for example:
"CONTENT_TYPE" => "application / json; charset = utf-8"
What I want are the headers, before they are processed, I am looking for:
"Content_Type" => "application / json; charset = utf-8"
I can easily go through request.env, looking for headings that start with HTTP_ and break them, the capital letters of each word and gsub to replace the underscores with dashes to get them in the format I want. It becomes harder to keep the original format this way when working with headers, for example:
"X-BT-RequestID"
I feel like I have to somehow get to the pre-processed headers.
I am writing an HTTP listener that will wrap a request and redirect it to another service, and I want to keep the headers in their original format. I know that the headers should be case insensitive, but if I can forward them in the original format, I can hope to prevent registration problems later, when my database users will request values based on these headers.
Any ideas?
source share