summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrajendrant <rajendrant@chromium.org>2016-03-08 18:50:40 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-09 02:52:18 +0000
commit69d5afea4afef524dbb4b4647ce90f78e83c4df7 (patch)
tree69fe8a15783ad22cd2ef6c9183813c5b44d5f610
parent96b815ed5228bf31607e4886edb60bfceef63abc (diff)
downloadchromium_src-69d5afea4afef524dbb4b4647ce90f78e83c4df7.zip
chromium_src-69d5afea4afef524dbb4b4647ce90f78e83c4df7.tar.gz
chromium_src-69d5afea4afef524dbb4b4647ce90f78e83c4df7.tar.bz2
Fix possible bypass-retry loop for 4xx responses with missing Via header
Data reduction proxy can get stuck in a bypass-retry loop on slow networks with >1second RTT, for the URL requests returning 4XX error. The reason is due to the 1-second bypass triggered on 4xx errors with no Via header. The fix is to change the 1-second bypass to block-once for the current request. BUG=502045 Review URL: https://codereview.chromium.org/1766633002 Cr-Commit-Position: refs/heads/master@{#380044}
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc4
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc41
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc8
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h5
4 files changed, 48 insertions, 10 deletions
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
index aff833d..ff58e6c 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
@@ -536,9 +536,9 @@ TEST_F(DataReductionProxyProtocolTest, BypassLogic) {
"Server: proxy\r\n\r\n",
true,
false,
- 1u,
+ 0u,
true,
- 1,
+ 0,
BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_4XX
},
// Invalid data reduction proxy response. Missing Via header.
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
index 0deda3d..b6469ba 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
@@ -888,9 +888,6 @@ TEST_F(DataReductionProxyBypassStatsEndToEndTest,
const char* initial_response_headers;
};
const TestCase test_cases[] = {
- { "DataReductionProxy.BypassedBytes.MissingViaHeader4xx",
- "HTTP/1.1 414 Request-URI Too Long\r\n\r\n",
- },
{ "DataReductionProxy.BypassedBytes.MissingViaHeaderOther",
"HTTP/1.1 200 OK\r\n\r\n",
},
@@ -952,4 +949,42 @@ TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesNetErrorOther) {
-net::ERR_PROXY_CONNECTION_FAILED, 1);
}
+TEST_F(DataReductionProxyBypassStatsEndToEndTest,
+ BypassedBytesMissingViaHeader4xx) {
+ InitializeContext();
+ const char* test_case_response_headers[] = {
+ "HTTP/1.1 414 Request-URI Too Long\r\n\r\n",
+ "HTTP/1.1 404 Not Found\r\n\r\n",
+ };
+ for (const char* test_case : test_case_response_headers) {
+ ClearBadProxies();
+ // The first request should be bypassed for missing Via header.
+ {
+ base::HistogramTester histogram_tester;
+ CreateAndExecuteRequest(GURL("http://foo.com"), test_case,
+ kErrorBody.c_str(), "HTTP/1.1 200 OK\r\n\r\n",
+ kBody.c_str());
+
+ histogram_tester.ExpectUniqueSample(
+ "DataReductionProxy.BypassedBytes.MissingViaHeader4xx", kBody.size(),
+ 1);
+ ExpectOtherBypassedBytesHistogramsEmpty(
+ histogram_tester,
+ "DataReductionProxy.BypassedBytes.MissingViaHeader4xx");
+ }
+ // The second request should be sent via the proxy.
+ {
+ base::HistogramTester histogram_tester;
+ CreateAndExecuteRequest(GURL("http://bar.com"),
+ "HTTP/1.1 200 OK\r\n"
+ "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n",
+ kNextBody.c_str(), nullptr, nullptr);
+ histogram_tester.ExpectUniqueSample(
+ "DataReductionProxy.BypassedBytes.NotBypassed", kNextBody.size(), 1);
+ ExpectOtherBypassedBytesHistogramsEmpty(
+ histogram_tester, "DataReductionProxy.BypassedBytes.NotBypassed");
+ }
+ }
+}
+
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
index 8945a02..fa9b6da 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
@@ -258,10 +258,10 @@ DataReductionProxyBypassType GetDataReductionProxyBypassType(
headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) {
// At this point, any 4xx response that is missing the via header
// indicates an issue that is scoped to only the current request, so only
- // bypass the data reduction proxy for a second.
- // TODO(sclittle): Change this to only bypass the current request once
- // that is fully supported, see http://crbug.com/418342.
- data_reduction_proxy_info->bypass_duration = TimeDelta::FromSeconds(1);
+ // bypass the data reduction proxy for the current request.
+ data_reduction_proxy_info->bypass_all = true;
+ data_reduction_proxy_info->mark_proxies_as_bad = false;
+ data_reduction_proxy_info->bypass_duration = TimeDelta();
return BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_4XX;
}
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h
index f243675..44f4528 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h
@@ -34,7 +34,10 @@ enum DataReductionProxyBypassType {
};
// Values for the bypass actions that can be specified by the Data Reduction
-// Proxy in response to a client request.
+// Proxy in response to a client request. These are explicit bypass actions
+// specified by the Data Reduction Proxy in the Chrome-Proxy header, block-once,
+// bypass=1, block=300, etc. These are not used for Chrome initiated bypasses
+// due to a server error, missing Via header, etc.
enum DataReductionProxyBypassAction {
#define BYPASS_ACTION_TYPE(label, value) BYPASS_ACTION_TYPE_##label = value,
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_bypass_action_list.h"