Add max retries to an HttpNetworkTransaction when an HTTP2 or QUIC related
IO Error occurs
Before this patch, HttpNetworkTransaction keeps resending the request in
an infinite loop if an HTTP2 or QUIC related IO Error occurs. We try to
add a limit to the number of retries (3 tries, including the first request)
BUG: 751642
Bug:
Change-Id: I3ab29dede0be0516f8706ec7e807f9febd56fed8
Reviewed-on: https://chromium-review.googlesource.com/602389
Commit-Queue: Matt Menke <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Cr-Commit-Position: refs/heads/master@{#494878}
diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h
index bd844a1..9ddb0b5 100644
--- a/net/http/http_network_transaction.h
+++ b/net/http/http_network_transaction.h
@@ -249,6 +249,10 @@
// should be resent in case of a socket reuse/close race.
bool ShouldResendRequest() const;
+ // Returns true if there have already been |kMaxRetryAttempts| retries for
+ // HTTP2 or QUIC network errors, and no further retries should be attempted.
+ bool HasExceededMaxRetries() const;
+
// Resets the connection and the request headers for resend. Called when
// ShouldResendRequest() is true.
void ResetConnectionAndRequestForResend();
@@ -402,6 +406,15 @@
// throttled state to the transaction.
std::unique_ptr<NetworkThrottleManager::Throttle> throttle_;
+ // Number of retries made for network errors like ERR_SPDY_PING_FAILED,
+ // ERR_SPDY_SERVER_REFUSED_STREAM, ERR_QUIC_HANDSHAKE_FAILED and
+ // ERR_QUIC_PROTOCOL_ERROR. Currently we stop after 3 tries
+ // (including the initial request) and fail the request.
+ // This count excludes retries on reused sockets since a well
+ // behaved server may time those out and thus the number
+ // of times we can retry a request on reused sockets is limited.
+ size_t retry_attempts_;
+
DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction);
};