Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc

Issue 2224003004: Add Accept-Encoding: br for secure data reduction proxy requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Accept-Encoding: br for secure data reduction proxy requests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
index 32cb51db7b0fd92a1472006e03ea33facd7a93c7..ade256bc4b6df9e0abc3ab75d61eda4f60095792 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
@@ -357,4 +357,43 @@ TEST_F(DataReductionProxyRequestOptionsTest, GetSessionKeyFromRequestHeaders) {
}
}
+TEST_F(DataReductionProxyRequestOptionsTest, AddBrotliAcceptEncoding) {
+ const struct {
+ const char* initial_accept_encoding;
+ bool brotli_enabled;
+ const char* expected_accept_encoding;
+ } tests[] = {
+ {nullptr, true, nullptr},
+ {"", true, "br"},
+ {"gzip", true, "gzip, br"},
+ {"gzip,br,foo", true, "gzip,br,foo"},
+ {"gzip, br , foo", true, "gzip, br , foo"},
+ {"gzip", false, "gzip"},
+ {"gzip, br", false, "gzip, br"},
+ };
+
+ for (const auto& test : tests) {
+ net::URLRequestContext context;
+ context.set_enable_brotli(test.brotli_enabled);
+ auto request = context.CreateRequest(GURL("http://foo"),
+ net::DEFAULT_PRIORITY, nullptr);
+ net::HttpRequestHeaders request_headers;
+ if (test.initial_accept_encoding) {
+ request_headers.SetHeader(net::HttpRequestHeaders::kAcceptEncoding,
+ test.initial_accept_encoding);
+ }
+
+ request_options()->AddBrotliAcceptEncoding(*request, &request_headers);
+
+ std::string actual_accept_encoding;
+ EXPECT_EQ(
+ request_headers.GetHeader(net::HttpRequestHeaders::kAcceptEncoding,
+ &actual_accept_encoding),
+ test.expected_accept_encoding != nullptr);
+ if (test.expected_accept_encoding) {
+ EXPECT_EQ(test.expected_accept_encoding, actual_accept_encoding);
+ }
+ }
+}
+
} // namespace data_reduction_proxy
« no previous file with comments | « components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698