summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-24 01:10:07 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-24 01:10:07 +0000
commit7a1180c7457b9ac79d4fa37e296a74e0e6655f79 (patch)
tree323e484220a0f4a7f090612f4b579299e74d2c03 /lib/net
parentaf9398ab38fa7b1f177b3079c80eb1131a2d693b (diff)
* lib/net/http.rb (Net::HTTP#transport_request): Fix infinite loop
upon EOFError or Errno::ECONNRESET where count is reset to 0. * test/net/http/test_http.rb (class TestNetHTTPKeepAlive): Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb48
1 files changed, 25 insertions, 23 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index b6e5de0a54..690690ae28 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1343,33 +1343,35 @@ module Net #:nodoc:
def transport_request(req)
count = 0
- begin_transport req
- res = catch(:response) {
- req.exec @socket, @curr_http_version, edit_path(req.path)
- begin
- res = HTTPResponse.read_new(@socket)
- end while res.kind_of?(HTTPContinue)
- res.reading_body(@socket, req.response_body_permitted?) {
- yield res if block_given?
+ begin
+ begin_transport req
+ res = catch(:response) {
+ req.exec @socket, @curr_http_version, edit_path(req.path)
+ begin
+ res = HTTPResponse.read_new(@socket)
+ end while res.kind_of?(HTTPContinue)
+ res.reading_body(@socket, req.response_body_permitted?) {
+ yield res if block_given?
+ }
+ res
}
+ end_transport req, res
res
- }
- end_transport req, res
- res
- rescue EOFError, Errno::ECONNRESET => exception
- if count == 0 && IDEMPOTENT_METHODS_.include?(req.method)
- count += 1
+ rescue EOFError, Errno::ECONNRESET => exception
+ if count == 0 && IDEMPOTENT_METHODS_.include?(req.method)
+ count += 1
+ @socket.close if @socket and not @socket.closed?
+ D "Conn close because of error #{exception}, and retry"
+ retry
+ end
+ D "Conn close because of error #{exception}"
+ @socket.close if @socket and not @socket.closed?
+ raise
+ rescue => exception
+ D "Conn close because of error #{exception}"
@socket.close if @socket and not @socket.closed?
- D "Conn close because of error #{exception}, and retry"
- retry
+ raise exception
end
- D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
- raise
- rescue => exception
- D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
- raise exception
end
def begin_transport(req)