-
Notifications
You must be signed in to change notification settings - Fork 968
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
headers hash should downcase keys so canonical header name can be used #38
Comments
This is fixed here: http://github.com/cap10morgan/httparty/compare/master...response_header_case_bug |
Thanks for the patch. Generally, I'd love it if HTTParty::Response was more API-compatible with Net::HTTPResponse and this issue is bringing us a little closer to that. While your patch fixes the case-sensitivity issue we'd still be returning a simple hash instead something that acts more like an HTTPResponse object. In this example, accessing the set-cookie header returns an array when it's accessed through HTTParty while Net::HTTP returns a comma delimited string.
I'm almost finished , just wanted to give you some context on why I'm moving towards another solution. |
Sounds good to me. Thanks for the explanation. |
Response headers accessible with mixed-case keys HTTParty::Response#response now returns the Net::HTTPResponse object for Closed by 179ef87 |
HTTParty::Response#response now returns the Net::HTTPResponse object for the request. Method missing now attempts to call the missing method on the HTTPResponse object when it doesn't exist on the parsed response object, i.e. HTTParty.get('http://example.com').get_fields('content-type') Closes jnunemakergh-38
In net-http, when you lookup a header in the headers hash, it overrides the method and downcases the key argument before grabbing the value from the internal data structure. HTTParty should do the same thing.
Right now, for example, doing this: response.headers['Cache-Control'] gives you a nil even though there is a "Cache-Control" header in the HTTP response. response.headers['cache-control'] works, however.
If no one disagrees that this is a bug that needs fixing, I'll take a crack at fixing it in a fork and issue a pull request.
The text was updated successfully, but these errors were encountered: