Friday, February 09, 2007

Ruby HTTPS with HTTP Basic Auth

Fetching HTTPS data with Ruby using HTTP Basic Authorization

require 'net/http'
require 'net/https'

def get_feed(server,path,username,password)
http = Net::HTTP.new(server,443)
req = Net::HTTP::Get.new(path)
http.use_ssl = true
req.basic_auth username, password
response = http.request(req)
return response.body
end

1 comments:

Melting Snowman said...

Thanks that helped.