# A bug in c:\\InstantRails\\ruby\\lib\\ruby\\1.8\\net\\http.rb?

**URL:** <https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326>\
**Category:** Ruby\
**Created:** [December 10, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326 "2008-12-10T17:20:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zloy](https://www.ruby-forum.com/u/zloy)\
**Post date:** [December 10, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326/1 "2008-12-10T17:20:18Z")

</div>

I can not make working a line of code:

http = Net::HTTP::Proxy(‘192.168.1.32’, 3128, ‘user’,  
‘password’).new(‘[http://www.yandex.ru](http://www.yandex.ru)’,80)

I got:  
stack level too deep

RAILS\_ROOT: C:/INSTAN~1/rails\_apps/myapp/config/…

Application Trace | Framework Trace | Full Trace  
C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:451:in `newobj' C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:451:in `newobj’  
C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:451:in `new' #{RAILS_ROOT}/lib/bot.rb:23:in `open\_url’  
#{RAILS\_ROOT}/app/controllers/urlas\_controller.rb:42:in `get\_content’

In http.rb at line 451 the method HTTP.new(bla, bla,…) is called which  
calls itself recurcively via its alias newobj. I’m new to ruby, so I can  
not figure out how to fix that. Have anybody met that issue already?

PS  
in  
C:\instantRails\ruby\lib\ruby\site\_ruby\1.8\rubygems\remote\_fetcher.rb I  
found the same way of using Net::HTTP::Proxy  
Net::HTTP::Proxy(@proxy\_uri.host, @proxy\_uri.port,  
unescape(@proxy\_uri.user), unescape(@proxy\_uri.password)).new(host,  
port)

but executing gem list -r --debug results in the different error w/o  
stack become too deep. I go ‘HTTP Responce 407’, despite I set  
http\_proxy env var to ‘[http://user:password@proxy-address](http://user:password@proxy-address):proxy-port’.  
That’s quite strange :[

Those two files use the same http.rb classes but behave differently

Any ideas appreciated.

---

<div class="post-metadata">

**Author:** ![zloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zloy](https://www.ruby-forum.com/u/zloy)\
**Post date:** [December 10, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326/2 "2008-12-10T18:00:57Z")

</div>

2008/12/10 Zhoran T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I can not make working a line of code:
> 
> http = Net::HTTP::Proxy(‘192.168.1.32’, 3128, ‘user’,  
> ‘password’).new(‘[http://www.yandex.ru](http://www.yandex.ru)’,80)
> 
> I got:  
> stack level too deep

I’ve no idea on the ins and outs of your error, but I’ve used the  
Proxy class like so in the past:

proxy\_class = Net::HTTP::Proxy(PROXY\_ADDRESS, PROXY\_PORT)

response = proxy\_class.start(uri.host, uri.port) {|http|  
http.get(uri.path, headers)  
}

…may or may not be good practice but it’s worked for me.

Rupert

---

<div class="post-metadata">

**Author:** ![zloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zloy](https://www.ruby-forum.com/u/zloy)\
**Post date:** [December 14, 2008, 11:34am UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326/3 "2008-12-14T11:34:53Z")

</div>

Hi Zhoran

> Thank you for your advice. I tried your code, but got again stack level  
> too deep. I think it’s because we use differrent lib versions.
> 
> Could you attach zipped ruby\lib\ruby\1.8 folder? It would help me a  
> lot.

not sure that’ll help that much as I’m just using the standard latest  
download of 1.8.6 from the ruby download pages.

I’ve often found that the best way to actually find out what’s going  
on when you get wierd errors/exceptions is to step through your source  
using ruby-debug as then you can find out exactly what’s going on with  
a bit of diligence find out why.

If you’ve not used the debugger before, I found the following  
screencasts useful:

[http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/](http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/)

> **[\#54 Debugging with ruby-debug - RailsCasts](http://railscasts.com/episodes/54-debugging-with-ruby-debug)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

Hope this helps

Rupert

---

<div class="post-metadata">

**Author:** ![zloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zloy](https://www.ruby-forum.com/u/zloy)\
**Post date:** [December 11, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326/4 "2008-12-11T16:30:16Z")

</div>

Rupert V. wrote:

> 2008/12/10 Zhoran T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > I can not make working a line of code:
> > 
> > http = Net::HTTP::Proxy(‘192.168.1.32’, 3128, ‘user’,  
> > ‘password’).new(‘[http://www.yandex.ru](http://www.yandex.ru)’,80)
> > 
> > I got:  
> > stack level too deep
> 
> I’ve no idea on the ins and outs of your error, but I’ve used the  
> Proxy class like so in the past:
> 
> proxy\_class = Net::HTTP::Proxy(PROXY\_ADDRESS, PROXY\_PORT)
> 
> response = proxy\_class.start(uri.host, uri.port) {|http|  
> http.get(uri.path, headers)  
> }
> 
> …may or may not be good practice but it’s worked for me.
> 
> Rupert

Hi, Rupert.  
Thank you for your advice. I tried your code, but got again stack level  
too deep. I think it’s because we use differrent lib versions.

Could you attach zipped ruby\lib\ruby\1.8 folder? It would help me a  
lot.

---

<div class="post-metadata">

**Author:** ![zloy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b4bc9f/32.png) [@zloy](https://www.ruby-forum.com/u/zloy)\
**Post date:** [December 15, 2008, 8:23am UTC](https://www.ruby-forum.com/t/a-bug-in-c-instantrails-ruby-lib-ruby-1-8-net-http-rb/155326/5 "2008-12-15T08:23:27Z")

</div>

Rupert V. wrote:

> Hi Zhoran
> 
> > Thank you for your advice. I tried your code, but got again stack level  
> > too deep. I think it’s because we use differrent lib versions.
> > 
> > Could you attach zipped ruby\lib\ruby\1.8 folder? It would help me a  
> > lot.
> 
> not sure that’ll help that much as I’m just using the standard latest  
> download of 1.8.6 from the ruby download pages.
> 
> I’ve often found that the best way to actually find out what’s going  
> on when you get wierd errors/exceptions is to step through your source  
> using ruby-debug as then you can find out exactly what’s going on with  
> a bit of diligence find out why.
> 
> If you’ve not used the debugger before, I found the following  
> screencasts useful:
> 
> [http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/](http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/)  
> [#54 Debugging with ruby-debug - RailsCasts](http://railscasts.com/episodes/54-debugging-with-ruby-debug)
> 
> Hope this helps
> 
> Rupert

Hi Rupert,  
Thank you for links about rdebug, I found them very useful. When I ran  
my code using rake it worked without any errors, but it still generates  
the error message while get running from within Rails controller. But  
I’m quite happy with running it with rake. So my question is closed.  
Wish you good luck!
