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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E760d621e0cc38664bf41b7869748b04?d=identicon&s=25 Sub Zero (zloy)
on 2008-12-10 17:20
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: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:proxy-port'.
That's quite strange :[

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

Any ideas appreciated.
Fb1fc6f2eccd067a19b298d89235bfe0?d=identicon&s=25 Rupert Voelcker (rupert)
on 2008-12-10 18:00
(Received via mailing list)
2008/12/10 Zhoran Tvalve <ztuaev@sibanthracite.ru>:
> 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
E760d621e0cc38664bf41b7869748b04?d=identicon&s=25 Sub Zero (zloy)
on 2008-12-11 16:30
Rupert Voelcker wrote:
> 2008/12/10 Zhoran Tvalve <ztuaev@sibanthracite.ru>:
>> 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.
Fb1fc6f2eccd067a19b298d89235bfe0?d=identicon&s=25 Rupert Voelcker (rupert)
on 2008-12-14 11:34
(Received via mailing list)
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/...
http://railscasts.com/episodes/54-debugging-with-ruby-debug

Hope this helps

Rupert
E760d621e0cc38664bf41b7869748b04?d=identicon&s=25 Sub Zero (zloy)
on 2008-12-15 08:23
Rupert Voelcker 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/...
> 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!
This topic is locked and can not be replied to.