This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Making an HTTPS Web Request
CodeExpectedActual
require 'net/https'
true true
require 'net/http'
uri = URI.parse("https://www.donotcall.gov/")
request = Net::HTTP.new(uri.host, uri.port) 
response = request.get("/")
Errno::ECONNRESET: Connection reset by peer
...
Errno::ECONNRESET: Connection reset by peer
	from /usr/lib/ruby/1.8/net/protocol.rb:133:in `sysread'
	from /usr/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
	from /usr/lib/ruby/1.8/timeout.rb:56:in `timeout'
	from /usr/lib/ruby/1.8/timeout.rb:76:in `timeout'
	from /usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
	from /usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
	from /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline'
	from /usr/lib/ruby/1.8/net/http.rb:1988:in `read_status_line'
	from /usr/lib/ruby/1.8/net/http.rb:1977:in `read_new'
	from /usr/lib/ruby/1.8/net/http.rb:1046:in `request'
	from /usr/lib/ruby/1.8/net/http.rb:1033:in `request'
	from /usr/lib/ruby/1.8/net/http.rb:545:in `start'
	from /usr/lib/ruby/1.8/net/http.rb:1031:in `request'
	from /usr/lib/ruby/1.8/net/http.rb:771:in `get'
	from (irb):5
	from :0
require 'net/https'
request.use_ssl = true
request.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = request.get("/")
#<Net::HTTPOK 200 OK readbody=true> #<Net::HTTPOK 200 OK readbody=true>
response.body.size
6537 6536
request = Net::HTTP.new(uri.host, uri.port) 
request.use_ssl = true
request.ca_path = "/etc/ssl/certs/"
request.verify_mode = OpenSSL::SSL::VERIFY_PEER
response = request.get("/")
#<Net::HTTPOK 200 OK readbody=true> #<Net::HTTPOK 200 OK readbody=true>