# Using Net::HTTP::Proxy Object

**URL:** <https://www.ruby-forum.com/t/using-net-proxy-object/173514>\
**Category:** Rails\
**Created:** [August 10, 2009, 8:36pm UTC](https://www.ruby-forum.com/t/using-net-proxy-object/173514 "2009-08-10T20:36:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 10, 2009, 8:36pm UTC](https://www.ruby-forum.com/t/using-net-proxy-object/173514/1 "2009-08-10T20:36:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 10, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/using-net-proxy-object/173514/2 "2009-08-10T22:36:10Z")

</div>

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](http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html#M000672)

hth  
ilan
