Bug #949: Net::HTTP timeout does not abandon request properly
http://redmine.ruby-lang.org/issues/show/949

Author: Anton Vaynshtok
Status: Open, Priority: Normal
Target version: Ruby 1.8.6

Note: I originally submitted this to the tracker at rubyforge.org, but I see that most of the tickets there are just being forwarded here.
---

It appears that when an http request times out the response is still correctly processed once it is received and returned
to the *next* request.

Here is a repro case. The server running localhost:3000 simply sleeps the amount of time specified in the sleep parameter
before returning an echo of the request.

<code>
#!/usr/bin/ruby

require 'net/http'
require 'pp'

Net::HTTP.start('localhost', 3000) do |http|
  http.read_timeout = 3

  begin
    response1 = http.request_get('/echo/echo?sleep=5')
  rescue Timeout::Error
    puts "first request timed out"
  end

  sleep 3

  response2 = http.request_get('/echo/echo?sleep=1')
  puts response2.body
end
</code>

When run, the code prints:
first request timed out
sleep=5

From looking at my server logs, the second request doesn't even seem to be made in this case; the response from request1
is simply returned to the next 'request_get' call.


----------------------------------------
http://redmine.ruby-lang.org