#8 new
bahuvrihi

Read request failures?

Reported by bahuvrihi | March 6th, 2009 @ 02:22 PM

When a request fails, for example due to a BadResponse, it would be helpful to dump the results, somehow. This is some debugging code that 'works' but not very well.


        res = ::Net::HTTP.new(uri.host, uri.port).start do |http| 
          yield(http, request) if block_given?
          
          begin
            http.request(request)
          rescue(Net::HTTPBadResponse)
            socket = http.instance_variable_get(:@socket)
            puts socket.read_all
            raise
          end
        end

I got an error by submitting the attached request. The output is:


% rap tap:load /Users/simonchiang/Desktop/request.yml --: tap-http:submit --: dump 
  I[14:22:31]               load /Users/simonchiang/Desktop/request.yml
  I[14:22:31]               POST https://bmf2.colorado.edu/cgi-bin/go-getter/login.py/handle_login
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Bad request!</title>
<link rev="made" href="mailto:hamady@colorado.edu" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/ 
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>Bad request!</h1>
<p>


    Your browser (or proxy) sent a request that
    this server could not understand.

</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:hamady@colorado.edu">webmaster</a>.

</p>

<h2>Error 400</h2>
<address>
  <a href="/">bmf2.colorado.edu</a><br />
  
  <span>Fri Mar  6 14:22:31 2009<br />
  Apache/2.2.3 (Linux/SUSE)</span>
</address>
</body>
</html>

  I[14:22:31] Net::HTTPBadResponse wrong status line: "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages