Created
May 24, 2012 19:50
-
-
Save webdesserts/2783822 to your computer and use it in GitHub Desktop.
This is a snippet of code for connecting to an https server via Ruby's Net::HTTP class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uri = URI('https://www.your-site.com/home/') | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
https.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
# use OpenSSL::SSL::VERIFY_PEER instead and https.ca_file for a verified cert | |
https.start do |http| | |
request = Net::HTTP::Get.new uri.request_uri | |
request.basic_auth 'username','password' | |
response = https.head('/home/') | |
response.each do |key, value| | |
puts key | |
puts ' '*3 + value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment