7
với Open :: URI, tôi có thể làm như sau:Hiển thị tiêu đề HTTP bằng cách sử dụng Open :: URI?
require 'open-uri'
#check status
open('http://google.com').status
#get entire html
open('http://google.com').read
Có thể lấy các tiêu đề HTTP được yêu cầu mọi thứ có thể được sửa lỗi, một cái gì đó giống như kiểu tóc xoăn 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
Điều này có khả thi không?