views:

42

answers:

2

Here's my code:

sock = Net::HTTP.new(url.host, url.port)
sock.use_ssl = true
response = sock.start {|http| http.request(req)}

here's the error:

undefined method `use_ssl=' for #<Net::HTTP www.paypal.com:443 open=false>

google is getting me nothing!

thanks.

+1  A: 

That is because the function is sock.use_ssl? and it returns a boolean, it is not a setter method.

It also appears to always return false. It is overridden in the Net::HTTPS package, which is probably what you should be using if you want to do any SSL stuff.

Here is the ruby doc

webdestroya
do you have any further information on this Net::HTTPS package. the only info i can find suggests the code that i have is in fact correct for setting Net::HTTP to use HTTPS...e.g. http://perfectionlabstips.wordpress.com/2008/11/03/how-to-open-a-https-session-in-ruby/
Chris
@Chris - I don't have any more info really. If you look at the ruby-library docs they show that the blog you are reading is incorrect.
webdestroya
A: 

be sure to require 'net/https' too!

DGM