http.get call works, but then fails when using debugger

Discussion in 'Ruby' started by Jeff Jortner, Nov 3, 2006.

  1. Jeff Jortner

    Jeff Jortner Guest

    Hi,
    Can someone tell me if I have found a bug or am doing something wrong
    using Net::HTTP.get ? If I run the code without the -rdebug flag, then
    it works perfectly. If I use the flag and then simply do a continue,
    then I get the errors shown after the code below. I have stepped
    through the code and shown that it is the get2 call that causes the
    error. Also happens with the get method.

    I/m running Ruby version 1.8.5 on both Mac (PowerPC) and Redhat
    Enterprise Linux. Same result on both.

    Jeff

    #!/usr/bin/ruby

    require 'net/http'

    SITE = "http://campus.acm.org"
    PATH = '/Public/fmr/'
    USERAGENT = ' Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
    AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3'
    http = Net::HTTP.new('campus.acm.org',80)
    puts " "
    puts "First Get"
    headers = {
    'Content-type' => 'application/x-www-form-urlencoded',
    'User-Agent' => USERAGENT,
    'Keep-Alive' => '300',
    'Connection' => 'keep-alive'
    }

    resp, data = http.get2(PATH, headers)
    puts 'Code= ' + resp.code

    ---------------
    spartan[293]ruby -rdebug jtest1.rb
    Debug.rb
    Emacs support available.

    jtest1.rb:3:require 'net/http'
    (rdb:1) c

    First Get
    /usr/local/lib/ruby/1.8/net/protocol.rb:133: `end of file reached'
    (EOFError)
    from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
    from /usr/local/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
    from /usr/local/lib/ruby/1.8/net/protocol.rb:104:in `read_all'
    from /usr/local/lib/ruby/1.8/net/http.rb:2217:in `read_body_0'
    from /usr/local/lib/ruby/1.8/net/http.rb:2170:in `read_body'
    from /usr/local/lib/ruby/1.8/net/http.rb:2195:in `body'
    from /usr/local/lib/ruby/1.8/net/http.rb:2134:in `reading_body'
    from /usr/local/lib/ruby/1.8/net/http.rb:1049:in `request'
    from /usr/local/lib/ruby/1.8/net/http.rb:1034:in `request'
    from /usr/local/lib/ruby/1.8/net/http.rb:543:in `start'
    from /usr/local/lib/ruby/1.8/net/http.rb:1032:in `request'
    from /usr/local/lib/ruby/1.8/net/http.rb:945:in `get2'
    from jtest1.rb:17
    /usr/local/lib/ruby/1.8/net/protocol.rb:133: @rbuf <<
    @io.sysread(1024)

    --
    Posted via http://www.ruby-forum.com/.
    Jeff Jortner, Nov 3, 2006
    #1
    1. Advertising

  2. Jeff Jortner

    Jan Svitok Guest

    On 11/3/06, Jeff Jortner <> wrote:
    > Hi,
    > Can someone tell me if I have found a bug or am doing something wrong
    > using Net::HTTP.get ? If I run the code without the -rdebug flag, then
    > it works perfectly. If I use the flag and then simply do a continue,
    > then I get the errors shown after the code below. I have stepped
    > through the code and shown that it is the get2 call that causes the
    > error. Also happens with the get method.
    >
    > I/m running Ruby version 1.8.5 on both Mac (PowerPC) and Redhat
    > Enterprise Linux. Same result on both.
    >
    > Jeff
    >
    > #!/usr/bin/ruby
    >
    > require 'net/http'
    >
    > SITE = "http://campus.acm.org"
    > PATH = '/Public/fmr/'
    > USERAGENT = ' Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
    > AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3'
    > http = Net::HTTP.new('campus.acm.org',80)
    > puts " "
    > puts "First Get"
    > headers = {
    > 'Content-type' => 'application/x-www-form-urlencoded',
    > 'User-Agent' => USERAGENT,
    > 'Keep-Alive' => '300',
    > 'Connection' => 'keep-alive'
    > }
    >
    > resp, data = http.get2(PATH, headers)
    > puts 'Code= ' + resp.code
    >
    > ---------------
    > spartan[293]ruby -rdebug jtest1.rb
    > Debug.rb
    > Emacs support available.
    >
    > jtest1.rb:3:require 'net/http'
    > (rdb:1) c
    >
    > First Get
    > /usr/local/lib/ruby/1.8/net/protocol.rb:133: `end of file reached'
    > (EOFError)
    > from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
    > from /usr/local/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
    > from /usr/local/lib/ruby/1.8/net/protocol.rb:104:in `read_all'
    > from /usr/local/lib/ruby/1.8/net/http.rb:2217:in `read_body_0'
    > from /usr/local/lib/ruby/1.8/net/http.rb:2170:in `read_body'
    > from /usr/local/lib/ruby/1.8/net/http.rb:2195:in `body'
    > from /usr/local/lib/ruby/1.8/net/http.rb:2134:in `reading_body'
    > from /usr/local/lib/ruby/1.8/net/http.rb:1049:in `request'
    > from /usr/local/lib/ruby/1.8/net/http.rb:1034:in `request'
    > from /usr/local/lib/ruby/1.8/net/http.rb:543:in `start'
    > from /usr/local/lib/ruby/1.8/net/http.rb:1032:in `request'
    > from /usr/local/lib/ruby/1.8/net/http.rb:945:in `get2'
    > from jtest1.rb:17
    > /usr/local/lib/ruby/1.8/net/protocol.rb:133: @rbuf <<
    > @io.sysread(1024)


    This is probably normal behaviour. Run your script with -w or -d
    switch and you'll see all exceptions. The debugger stops on all
    excetions even if they are caught.
    Jan Svitok, Nov 3, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. Craig
    Replies:
    2
    Views:
    6,072
    M. Craig
    Nov 19, 2003
  2. Scott
    Replies:
    2
    Views:
    656
    Gregory A. Beamer
    Nov 13, 2008
  3. Simonk

    Call via vb .net fails but soap toolkit works

    Simonk, Jan 18, 2006, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    171
    Josh Twist
    Jan 18, 2006
  4. Replies:
    0
    Views:
    270
  5. Replies:
    2
    Views:
    288
    Grant Wagner
    Dec 23, 2004
Loading...

Share This Page