Get a secure way of sending sensitive information to the remote server: : HTTPS « Network « Ruby






Get a secure way of sending sensitive information to the remote server:


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::Post.new(url.path)
request.set_form_data({ 'credit_card_number' => '1234123412341234' })
puts http.request(request).body

 








Related examples in the same category

1.Secure HTTP with HTTPS
2.Making an HTTPS Web Request
3.Set verify mode for https
4.verify_mode = OpenSSL::SSL::VERIFY_PEER