Skip to content
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

Closed
CraigStuntz opened this issue Jun 29, 2012 · 8 comments
Closed

README request["SOME_HEADER"] documentation incorrect. #542

CraigStuntz opened this issue Jun 29, 2012 · 8 comments
Labels
Milestone

Comments

@CraigStuntz
Copy link

The README says:

request["SOME_HEADER"]      # value of SOME_HEADER header

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.

@kgrz
Copy link
Member

kgrz commented Jul 19, 2012

@CraigStuntz Yes. it should be `request.env["SOME_HEADER"]. Mind if I sent a pull request?

@CraigStuntz
Copy link
Author

@kgrz That's fine, but request["SOME_PARAM"] also has value. It just doesn't include headers. Maybe it should say:

request["SOME_PARAM"]      # value of SOME_PARAM request param

?

@kgrz
Copy link
Member

kgrz commented Jul 20, 2012

It returned nil. request cannot be queried that way as far as know. Unlike env which is a hash.

@CraigStuntz
Copy link
Author

Hmm... The source code and the docs say otherwise. Have you tested?

@kgrz
Copy link
Member

kgrz commented Jul 20, 2012

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.

@kgrz
Copy link
Member

kgrz commented Jul 20, 2012

Oh. I think you meant the same thing right? :-) Perhaps I got carried away by the capital "SOME_VALUE" there. My mistake.

@rkh
Copy link
Member

rkh commented Aug 31, 2012

Pull Request for better docs welcome. You'll get karma points.

@kgrz
Copy link
Member

kgrz commented Sep 4, 2012

Modified accordingly: 6ec1aa4

rkh pushed a commit that referenced this issue Sep 4, 2012
#542. request["SOME_HEADER"]
is a little confusing since the [] operator on request object is a 
shortcut to the params hash. And thus, request["key"] is same as 
params["key"]. Updated the same thing.
@rkh rkh closed this as completed in ddbba34 Sep 4, 2012
rkh pushed a commit that referenced this issue Jan 9, 2013
#542. request["SOME_HEADER"]
is a little confusing since the [] operator on request object is a 
shortcut to the params hash. And thus, request["key"] is same as 
params["key"]. Updated the same thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants