HTTP is a plain text, unencrypted protocol, and this makes it unsuitable for transferring
sensitive data such as credit card information. HTTPS is the solution, as it’s the same as HTTP but routed over Secure Socket Layer (SSL), which makes it unreadable to any third parties.
Ruby’s net/https library makes it possible to access HTTPS URLs, and you can make net/http use it semi-transparently by setting the use_ssl attribute on a Net::HTTP instance to true, like so:

require 'net/http'
require 'net/https'
url = URI.parse('https://example.com/')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == 'https'
request = Net::HTTP::Get.new(url.path)
puts http.request(request).body
Advertisements