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

8 comments:

Melting Snowman said...

Thanks that helped.

Anonymous said...

thanks

goaasim said...

Thanks a ton. This was very helpful.

Anonymous said...

Thanks !

Anonymous said...

Great help, thanks!

mole removal at home said...

I was very happy that I found this site. I want to to thank you for this great information!! I certainly enjoyed every bit of it and I have bookmarked your blog to see the new stuff you post in the future

Unknown said...

Awesome. Thanks. I have been trying to get this done since night yesterday.. Worked after i saw it here. very clear and concise!

indiana jones raiders of the lost ark coat hanger said...

My friends love this post that carry a high profile stuff. thanks for all that.