require 'uri'
require 'net/http'
url = 'https://example.com/'
uri = URI(url)
uri.host = 'coffeescript.org' # change host
puts Net::HTTP.get(uri)[0, 256]
# Returns coffeescript page
url = 'http://coffeescript.org/'
uri = URI(url)
uri.scheme = 'https' # change scheme
puts Net::HTTP.get(uri)
# OpenSSL::SSL::SSLSocket#connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=... state=error: record layer failure