dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] net/http: retryable exception is configurable
@ 2015-07-18  8:22 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-07-18  8:22 UTC (permalink / raw)
  To: spew

---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-18  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-18  8:22 [PATCH] net/http: retryable exception is configurable Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).