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

use EventMachine::HttpResponseHeader#raw in example #315

Conversation

takada-s
Copy link

@takada-s takada-s commented Jun 4, 2015

examples/http_log.rb is very helpful for me.
I noticed that the response header handling can be more simple by using EventMachine::HttpResponseHeader#raw. (definition here)

resp.response_header.each_pair do |k, v|
response_headers[to_http_header(k)] = v
end
response_headers = resp.response_header.raw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops the to_http_header() call that the old method is doing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my environment, response_header.raw() returns well-formed hash like this:

resp.response_header:
{"CONTENT_TYPE"=>"text/html",
 "DATE"=>"Fri, 05 Jun 2015 01:01:07 GMT",
 "CONNECTION"=>"close",
 "TRANSFER_ENCODING"=>"chunked"}
resp.response_header.raw:
{"Content-Type"=>"text/html",
 "Date"=>"Fri, 05 Jun 2015 01:01:07 GMT",
 "Connection"=>"close",
 "Transfer-Encoding"=>"chunked"}

( I used pp resp.response_header and pp resp.response_header.raw)

@igrigorik igrigorik closed this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants