diff options
author | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 17:54:55 +0000 |
---|---|---|
committer | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 17:54:55 +0000 |
commit | 313feebdc8dc898e4cccae929096a0a40474da11 (patch) | |
tree | e1129a02f3412c007e215652199c03e67cadc576 /net/http/http_response_headers_unittest.cc | |
parent | 49128c94b9d163f5f4824a7d87e965bae4f821b7 (diff) | |
download | chromium_src-313feebdc8dc898e4cccae929096a0a40474da11.zip chromium_src-313feebdc8dc898e4cccae929096a0a40474da11.tar.gz chromium_src-313feebdc8dc898e4cccae929096a0a40474da11.tar.bz2 |
Fix UMA reporting of data reduction proxy bypass reasons
5xx responses from the proxy that should induce proxy bypass were previously reported as bypassing due to a missing via header value, because such responses often also are missing that header value. This change fixes that reporting.
BUG=356445
Review URL: https://codereview.chromium.org/212873004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_response_headers_unittest.cc')
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 0b17b8f..f73e176 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -13,6 +13,10 @@ #include "net/http/http_response_headers.h" #include "testing/gtest/include/gtest/gtest.h" +#if defined(SPDY_PROXY_AUTH_ORIGIN) +#include "net/proxy/proxy_service.h" +#endif + namespace { struct TestData { @@ -2172,4 +2176,77 @@ TEST(HttpResponseHeadersTest, IsChromeProxyResponse) { EXPECT_EQ(tests[i].expected_result, parsed->IsChromeProxyResponse()); } } + +TEST(HttpResponseHeadersTest, GetChromeProxyBypassEventType) { + const struct { + const char* headers; + net::ProxyService::DataReductionProxyBypassEventType expected_result; + } tests[] = { + { "HTTP/1.1 200 OK\n" + "Chrome-Proxy: bypass=0\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::SHORT_BYPASS, + }, + { "HTTP/1.1 200 OK\n" + "Chrome-Proxy: bypass=1799\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::SHORT_BYPASS, + }, + { "HTTP/1.1 200 OK\n" + "Chrome-Proxy: bypass=1800\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::LONG_BYPASS, + }, + { "HTTP/1.1 500 Internal Server Error\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::INTERNAL_SERVER_ERROR_BYPASS, + }, + { "HTTP/1.1 501 Not Implemented\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::BYPASS_EVENT_TYPE_MAX, + }, + { "HTTP/1.1 502 Bad Gateway\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::INTERNAL_SERVER_ERROR_BYPASS, + }, + { "HTTP/1.1 503 Service Unavailable\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::INTERNAL_SERVER_ERROR_BYPASS, + }, + { "HTTP/1.1 504 Gateway Timeout\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::BYPASS_EVENT_TYPE_MAX, + }, + { "HTTP/1.1 505 HTTP Version Not Supported\n" + "Via: 1.1 Chrome-Compression-Proxy\n", + net::ProxyService::BYPASS_EVENT_TYPE_MAX, + }, + { "HTTP/1.1 304 Not Modified\n", + net::ProxyService::BYPASS_EVENT_TYPE_MAX, + }, + { "HTTP/1.1 200 OK\n", + net::ProxyService::MISSING_VIA_HEADER, + }, + { "HTTP/1.1 200 OK\n" + "Chrome-Proxy: bypass=1799\n", + net::ProxyService::SHORT_BYPASS, + }, + { "HTTP/1.1 502 Bad Gateway\n", + net::ProxyService::INTERNAL_SERVER_ERROR_BYPASS, + }, + { "HTTP/1.1 502 Bad Gateway\n" + "Chrome-Proxy: bypass=1799\n", + net::ProxyService::SHORT_BYPASS, + }, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + std::string headers(tests[i].headers); + HeadersToRaw(&headers); + scoped_refptr<net::HttpResponseHeaders> parsed( + new net::HttpResponseHeaders(headers)); + net::HttpResponseHeaders::ChromeProxyInfo chrome_proxy_info; + EXPECT_EQ(tests[i].expected_result, + parsed->GetChromeProxyBypassEventType(&chrome_proxy_info)); + } +} #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |