From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] net/http: retryable exception is configurable
Date: Sat, 18 Jul 2015 08:22:45 +0000 [thread overview]
Message-ID: <1437207765-1448-1-git-send-email-e@80x24.org> (raw)
---
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
reply other threads:[~2015-07-18 8:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437207765-1448-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).