【发布时间】:2012-12-17 14:29:20
【问题描述】:
使用 Open::URI,我可以执行以下操作:
require 'open-uri'
#check status
open('http://google.com').status
#get entire html
open('http://google.com').read
是否可以获取请求的 HTTP 标头以便调试事情,例如 Curls 的 curl -I http://google.com?
$ curl -I google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Mon, 17 Dec 2012 14:28:17 GMT
Expires: Wed, 16 Jan 2013 14:28:17 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
这可能吗?
【问题讨论】: