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


#1

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’,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:innewobj’
C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:451:in new' #{RAILS_ROOT}/lib/bot.rb:23:inopen_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:proxy-port’.
That’s quite strange :[

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

Any ideas appreciated.


#2

2008/12/10 Zhoran T. 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’,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


#3

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://railscasts.com/episodes/54-debugging-with-ruby-debug

Hope this helps

Rupert


#4

Rupert V. wrote:

2008/12/10 Zhoran T. 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’,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.


#5

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://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!