From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: spew@80x24.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9938163384D for ; Sat, 18 Jul 2015 08:22:45 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] net/http: retryable exception is configurable Date: Sat, 18 Jul 2015 08:22:45 +0000 Message-Id: <1437207765-1448-1-git-send-email-e@80x24.org> List-Id: --- lib/net/http.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 4db69b6..918a680 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -661,6 +661,11 @@ module Net #:nodoc: SSL_IVNAMES.each do |ivname| instance_variable_set ivname, nil end + + @retryable_exception = [ Net::ReadTimeout, IOError, EOFError, + Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, Timeout::Error ] + # avoid a dependency on OpenSSL + @retryable_exception << OpenSSL::SSL::SSLError if defined?(OpenSSL::SSL) end def inspect @@ -1452,7 +1457,8 @@ module Net #:nodoc: # avoid a dependency on OpenSSL defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError, Timeout::Error => exception - if count == 0 && IDEMPOTENT_METHODS_.include?(req.method) + if count == 0 && IDEMPOTENT_METHODS_.include?(req.method) && + @retryable_exception.any? { |c| c === exception } count += 1 @socket.close if @socket and not @socket.closed? D "Conn close because of error #{exception}, and retry" -- EW