通过https从ruby Net :: HTTP获取跟踪

时间:2013-08-29 07:43:29

标签: ruby http

我希望能够从ruby的Net :: HTTP for https获取完整的HTTP跟踪。目前我正在检查调试器中的内容,如下所示:

(rdb:1) response
#<Net::HTTPFound 302 FOUND readbody=true>
(rdb:1) response.each_header {|x| puts x}
content-type
date
location
server
vary
content-length
connection
{"content-type"=>["text/html; charset=utf-8"], "date"=>["Wed, 28 Aug 2013 16:13:44 GMT"], "location"=>["https://example.com/login?next=/stuff"], "server"=>["nginx/1.1.19"], "vary"=>["Cookie"], "content-length"=>["0"], "connection"=>["keep-alive"]}

这真的很有帮助,但我只是喜欢看原始HTTP,例如

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

有没有办法只转储HTTP请求和响应的副本而不经过中间处理来重构它们?

非常感谢提前

1 个答案:

答案 0 :(得分:1)

我认为从Net :: HTTPResponse获取原始HTTP标头是不可能的,因为它在接收数据时解析标头。见HTTPResponse#read_new