Forum: Ruby on Rails SystemStackError: stack level too deep

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.
D51a24ae1017f53158d70b621494255d?d=identicon&s=25 Bontina Chen (abon)
on 2007-01-31 13:08
I'm testing the http module in console.
BUt I got the following error.
Anyone knows why?

>> Net::HTTP.get_print 'www.google.com', 'index.html'
SystemStackError: stack level too deep
        from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
`newobj'
        from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
`newobj'
        from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:451:in `new'
        from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:374:in
`get_response'

        from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:337:in
`get_print'
        from (irb):2

THX
Fd5b8048d157a919043272d6292cb2b1?d=identicon&s=25 alex (Guest)
on 2007-02-01 11:43
(Received via mailing list)
Try posting your question on refwell.com I got my answer there quite
quickly
U welcome:)

On Jan 31, 1:08 pm, Bontina Chen <rails-mailing-l...@andreas-s.net>
E760d621e0cc38664bf41b7869748b04?d=identicon&s=25 Sub Zero (zloy)
on 2008-12-10 11:17
Bontina Chen wrote:
> I'm testing the http module in console.
> BUt I got the following error.
> Anyone knows why?
>
>>> Net::HTTP.get_print 'www.google.com', 'index.html'
> SystemStackError: stack level too deep
>         from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
> `newobj'
>         from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
> `newobj'
>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:451:in `new'
>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:374:in
> `get_response'
>
>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:337:in
> `get_print'
>         from (irb):2
>
> THX

Hi, I'm also suffering from that issue. Please help!
A copy-pasted an example of using 'http.rb'

  def open_url(_url)
   http = Net::HTTP.new('http://www.yandex.ru', nil, '192.168.1.32',
3128)
   http.start{
     case req.request_method
     when "GET"  then response = http.get(path, header)
     when "POST" then response = http.post(path, req.body || "", header)
     when "HEAD" then response = http.head(path, header)
     else
       raise HTTPStatus::MethodNotAllowed,
         "unsupported method `#{req.request_method}'."
     end
   }
   end

and constantly got an exception inside start. I tried several examples I
found in doc, but wo change - I always got that exception message.

---------------------------------------------------------------------
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'
C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:440:in `start'
#{RAILS_ROOT}/lib/bot.rb:25:in `open_url'
#{RAILS_ROOT}/app/controllers/urlas_controller.rb:42:in `get_content'
---------------------------------------------------------------------
E760d621e0cc38664bf41b7869748b04?d=identicon&s=25 Sub Zero (zloy)
on 2008-12-10 11:22
Zhoran Tvalve wrote:
> Bontina Chen wrote:
>> I'm testing the http module in console.
>> BUt I got the following error.
>> Anyone knows why?
>>
>>>> Net::HTTP.get_print 'www.google.com', 'index.html'
>> SystemStackError: stack level too deep
>>         from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
>> `newobj'
>>         from C:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:451:in
>> `newobj'
>>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:451:in `new'
>>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:374:in
>> `get_response'
>>
>>         from C:/InstantRails/ruby/lib/ruby/1.8/net\http.rb:337:in
>> `get_print'
>>         from (irb):2
>>
>> THX
>
> Hi, I'm also suffering from that issue. Please help!
> A copy-pasted an example of using 'http.rb'
>
>   def open_url(_url)
>    http = Net::HTTP.new('http://www.yandex.ru', nil, '192.168.1.32',
> 3128)
>    http.start{
>      case req.request_method
>      when "GET"  then response = http.get(path, header)
>      when "POST" then response = http.post(path, req.body || "", header)
>      when "HEAD" then response = http.head(path, header)
>      else
>        raise HTTPStatus::MethodNotAllowed,
>          "unsupported method `#{req.request_method}'."
>      end
>    }
>    end
>
> and constantly got an exception inside start. I tried several examples I
> found in doc, but wo change - I always got that exception message.
>
> ---------------------------------------------------------------------
> 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'
> C:/INSTAN~1/ruby/lib/ruby/1.8/net/http.rb:440:in `start'
> #{RAILS_ROOT}/lib/bot.rb:25:in `open_url'
> #{RAILS_ROOT}/app/controllers/urlas_controller.rb:42:in `get_content'
> ---------------------------------------------------------------------


Here is that code from 'net/http.rb'. I suppose that recursion is in
charge, but I could not find out what is wrong:

 def HTTP.start(address, port = nil, p_addr = nil, p_port = nil, p_user
= nil, p_pass = nil, &block) # :yield: +http+
   new(address, port, p_addr, p_port, p_user, p_pass).start(&block)
 end

 class << HTTP
   alias newobj new
 end

 # Creates a new Net::HTTP object.
 # If +proxy_addr+ is given, creates an Net::HTTP object with proxy
support.
 # This method does not open the TCP connection.
 def HTTP.new(address, port = nil, p_addr = nil, p_port = nil, p_user =
nil, p_pass = nil)
   h = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port)
   h.instance_eval {
     @newimpl = ::Net::HTTP.version_1_2?
   }
   h
 end

 # Creates a new Net::HTTP object for the specified +address+.
 # This method does not open the TCP connection.
 def initialize(address, port = nil)
   @address = address
   @port    = (port || HTTP.default_port)
   @curr_http_version = HTTPVersion
   @seems_1_0_server = false
   @close_on_empty_response = false
   @socket  = nil
   @started = false
   @open_timeout = nil
   @read_timeout = 60
   @debug_output = nil
   @use_ssl = false
   @ssl_context = nil
 end
This topic is locked and can not be replied to.