Using Net::HTTP::Proxy Object

I have been testing some web service calls that I am able to
successfully make as long as I am connecting to the development
environment which is on the inside of our corporate firewall, but when I
attempt to connect to the production web servers on the other side of
the firewall, I never get anything back. I am about 90% sure that the
reason behind it is because I’m not calling the Proxy object correctly.

When I create the object in the dev environment I am creating the object
like this:

http = Net::HTTP.new(@url, @port)

And then when I need to use the object I am calling it like this:

resp, data = http.post(path, data, headers)

However, when I am trying to get through the proxy I don’t understand
the documentation on how to create the proxy object. I had tried this:

http = Net::HTTP::Proxy(@proxy_addr,@proxy_port).new(@url,@port)

Because I thought that the proxy object had the exacy same methods
available as the HTTP object without the proxy but I am getting nil when
attempting to create the object.

Does anyone have some sample that can help me create the proxied HTTP
object so that I can call the post method in the same manner that my
code does in the non-firewall environment?

David Sainte-claire wrote:

change:

http = Net::HTTP::Proxy(@proxy_addr,@proxy_port).new(@url,@port)

to

http = Net::HTTP::Proxy(@proxy_addr,@proxy_port).start(@url,@port)

please refer to:
http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M000672

hth
ilan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs