使用 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
这可能吗?