diff options
author | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-15 12:19:52 +0000 |
---|---|---|
committer | bengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-15 12:19:52 +0000 |
commit | cefb81130fcc85a5de0b737be52380a22b437574 (patch) | |
tree | a6c1e7b0d16272939e459446dce5d3f6c70e01cb /net/http/http_response_headers_unittest.cc | |
parent | 344a02931fcd9f58e602bd0a1cdf2dde97737d77 (diff) | |
download | chromium_src-cefb81130fcc85a5de0b737be52380a22b437574.zip chromium_src-cefb81130fcc85a5de0b737be52380a22b437574.tar.gz chromium_src-cefb81130fcc85a5de0b737be52380a22b437574.tar.bz2 |
Moved data reduction proxy header processing out of net
BUG=367221
Review URL: https://codereview.chromium.org/318753005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277314 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 | 333 |
1 files changed, 0 insertions, 333 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index b097a18..cc236d1 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -13,10 +13,6 @@ #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 { @@ -1939,332 +1935,3 @@ 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; - bool expected_bypass_all; - } tests[] = { - { "HTTP/1.1 200 OK\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=86400\n" - "Content-Length: 999\n", - true, - 86400, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=0\n" - "Content-Length: 999\n", - true, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=-1\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=xyz\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: foo=abc, bypass=86400\n" - "Content-Length: 999\n", - true, - 86400, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=86400, bar=abc\n" - "Content-Length: 999\n", - true, - 86400, - false, - }, - { "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, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=3600, bypass=86400\n" - "Content-Length: 999\n", - true, - 3600, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=, bypass=86400\n" - "Content-Length: 999\n", - true, - 86400, - false, - }, - { "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, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: block=, block=3600\n" - "Content-Length: 999\n", - true, - 3600, - true, - }, - { "HTTP/1.1 200 OK\n" - "connection: keep-alive\n" - "Chrome-Proxy: bypass=86400, block=3600\n" - "Content-Length: 999\n", - true, - 3600, - true, - }, - { "HTTP/1.1 200 OK\n" - "connection: proxy-bypass\n" - "Chrome-Proxy: block=, bypass=86400\n" - "Content-Length: 999\n", - true, - 86400, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: proxy-bypass\n" - "Chrome-Proxy: block=-1\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - { "HTTP/1.1 200 OK\n" - "connection: proxy-bypass\n" - "Chrome-Proxy: block=99999999999999999999\n" - "Content-Length: 999\n", - false, - 0, - false, - }, - }; - 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::DataReductionProxyInfo data_reduction_proxy_info; - EXPECT_EQ(tests[i].expected_result, - parsed->GetDataReductionProxyInfo(&data_reduction_proxy_info)); - EXPECT_EQ(tests[i].expected_retry_delay, - data_reduction_proxy_info.bypass_duration.InSeconds()); - EXPECT_EQ(tests[i].expected_bypass_all, - data_reduction_proxy_info.bypass_all); - } -} -#endif // defined(SPDY_PROXY_AUTH_ORIGIN) - -TEST(HttpResponseHeadersTest, IsDataReductionProxyResponse) { - const struct { - const char* headers; - bool expected_result; - } tests[] = { - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome-Proxy\n", - false, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1\n", - false, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome-Compression-Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.0 Chrome-Compression-Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Foo-Bar, 1.1 Chrome-Compression-Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome-Compression-Proxy, 1.1 Bar-Foo\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 chrome-compression-proxy\n", - false, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Foo-Bar\n" - "Via: 1.1 Chrome-Compression-Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome-Proxy\n", - false, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome Compression Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Foo-Bar, 1.1 Chrome Compression Proxy\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Chrome Compression Proxy, 1.1 Bar-Foo\n", - true, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 chrome compression proxy\n", - false, - }, - { "HTTP/1.1 200 OK\n" - "Via: 1.1 Foo-Bar\n" - "Via: 1.1 Chrome Compression Proxy\n", - true, - }, - }; - 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)); - - EXPECT_EQ(tests[i].expected_result, parsed->IsDataReductionProxyResponse()); - } -} - -#if defined(SPDY_PROXY_AUTH_ORIGIN) -TEST(HttpResponseHeadersTest, GetDataReductionProxyBypassEventType) { - 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, - }, - { "HTTP/1.1 502 Bad Gateway\n" - "Chrome-Proxy: bypass=1799\n", - net::ProxyService::SHORT_BYPASS, - }, - { "HTTP/1.1 414 Request-URI Too Long\n", - net::ProxyService::PROXY_4XX_BYPASS, - }, - { "HTTP/1.1 414 Request-URI Too Long\n" - "Via: 1.1 Chrome-Compression-Proxy\n", - net::ProxyService::BYPASS_EVENT_TYPE_MAX, - } - }; - 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::DataReductionProxyInfo chrome_proxy_info; - EXPECT_EQ(tests[i].expected_result, - parsed->GetDataReductionProxyBypassEventType(&chrome_proxy_info)); - } -} -#endif // defined(SPDY_PROXY_AUTH_ORIGIN) |