diff options
author | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:17:40 +0000 |
---|---|---|
committer | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:17:40 +0000 |
commit | 3d498f757ecce8dd3a8d77ab71c5c6249bd9ac64 (patch) | |
tree | 5b735db3b8500bb2a3244a124563f336e7d62a11 /net/http/http_response_headers_unittest.cc | |
parent | ba570755b30f617e177c4575d34b0aecfccc3ada (diff) | |
download | chromium_src-3d498f757ecce8dd3a8d77ab71c5c6249bd9ac64.zip chromium_src-3d498f757ecce8dd3a8d77ab71c5c6249bd9ac64.tar.gz chromium_src-3d498f757ecce8dd3a8d77ab71c5c6249bd9ac64.tar.bz2 |
Added support for a new HTTP response header called Chrome-Proxy, which is restricted to only the data compression proxy. The header carries a comma-separated list of instructions for proxy/Chrome interaction. This change introduces one instruction, "bypass," which specifies a number of seconds that Chrome should bypass the proxy.
BUG=306631
Review URL: https://codereview.chromium.org/26515005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231404 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 | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 8bde289e..5904bea 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -1877,3 +1877,128 @@ TEST(HttpResponseHeadersTest, ToNetLogParamAndBackAgain) { parsed->GetNormalizedHeaders(&normalized_recreated); EXPECT_EQ(normalized_parsed, normalized_recreated); } + +#if defined(SPDY_PROXY_AUTH_ORIGIN) +TEST(HttpResponseHeadersTest, GetProxyBypassInfo) { + const struct { + const char* headers; + bool expected_result; + int64 expected_retry_delay; + } tests[] = { + { "HTTP/1.1 200 OK\n" + "Content-Length: 999\n", + false, + 0, + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Content-Length: 999\n", + false, + 0, + }, + { "HTTP/1.1 200 OK\n" + "connection: proxy-bypass\n" + "Content-Length: 999\n", + true, + 0, + }, + { "HTTP/1.1 200 OK\n" + "connection: proxy-bypass\n" + "Chrome-Proxy: bypass=86400\n" + "Content-Length: 999\n", + true, + 86400 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=86400\n" + "Content-Length: 999\n", + true, + 86400 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=0\n" + "Content-Length: 999\n", + true, + 0 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=-1\n" + "Content-Length: 999\n", + false, + 0 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=xyz\n" + "Content-Length: 999\n", + false, + 0 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass\n" + "Content-Length: 999\n", + false, + 0 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: foo=abc, bypass=86400\n" + "Content-Length: 999\n", + true, + 86400 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=86400, bar=abc\n" + "Content-Length: 999\n", + true, + 86400 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=3600\n" + "Chrome-Proxy: bypass=86400\n" + "Content-Length: 999\n", + true, + 3600 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=3600, bypass=86400\n" + "Content-Length: 999\n", + true, + 3600 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass=, bypass=86400\n" + "Content-Length: 999\n", + true, + 86400 + }, + { "HTTP/1.1 200 OK\n" + "connection: keep-alive\n" + "Chrome-Proxy: bypass\n" + "Chrome-Proxy: bypass=86400\n" + "Content-Length: 999\n", + true, + 86400 + }, + }; + 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)); + + base::TimeDelta duration; + EXPECT_EQ(tests[i].expected_result, + parsed->GetChromeProxyInfo(&duration)); + EXPECT_EQ(tests[i].expected_retry_delay, duration.InSeconds()); + } +} +#endif // defined(SPDY_PROXY_AUTH_ORIGIN) |