I’m making an HTTP request with Ruby using Net::HTTP, and I can’t figure out how to get all the response headers.
I tried response.header and response.headers and nothing is working.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The response object actually contains the headers.
See “Net::HTTPResponse” for more infomation.
You can do:
You can also call
each_headeroreachon the response object to iterate through the headers.If you really want the headers outside of the response object, call
response.to_hash