-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
README request["SOME_HEADER"] documentation incorrect. #542
Comments
@CraigStuntz Yes. it should be `request.env["SOME_HEADER"]. Mind if I sent a pull request? |
@kgrz That's fine, but
? |
It returned nil. request cannot be queried that way as far as know. Unlike env which is a hash. |
Hmm... The source code and the docs say otherwise. Have you tested? |
Yes, I've tested it. In the Rack Request docs, it says that [] is a shortcut to 'request.params' hash. This is the GET and POST params hash and not the headers hash. So request["HTTP_REFERER"] returns a nil. However, request[:query] will return "Hello" provided the url is http://localhost/?query=Hello. I've tested the headers part am I'm sure about that. The second part is what I infer from the docs and Rack source. Sorry about lack of proper formatting. My phone keypad doesn't have a backticks key. |
Oh. I think you meant the same thing right? :-) Perhaps I got carried away by the capital "SOME_VALUE" there. My mistake. |
Pull Request for better docs welcome. You'll get karma points. |
Modified accordingly: 6ec1aa4 |
The README says:
This is wrong. Rack doesn't put headers in the params hash, just form data and query strings. Sinatra doesn't override this, either.
As far as I can tell, the only way to get request headers is via
env
.The text was updated successfully, but these errors were encountered: