#include <vector>
+#include "components/data_reduction_proxy/common/data_reduction_proxy_headers_test_utils.h"
#include "net/http/http_response_headers.h"
#include "net/proxy/proxy_service.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
-
-// Transform "normal"-looking headers (\n-separated) to the appropriate
-// input format for ParseRawHeaders (\0-separated).
-void HeadersToRaw(std::string* headers) {
- std::replace(headers->begin(), headers->end(), '\n', '\0');
- if (!headers->empty())
- *headers += '\0';
-}
-
-} // namespace
-
namespace data_reduction_proxy {
class DataReductionProxyHeadersTest : public testing::Test {};
std::string action_value;
bool has_action_key = GetDataReductionProxyActionValue(
- parsed, tests[i].action_key, &action_value);
+ parsed.get(), tests[i].action_key, &action_value);
EXPECT_EQ(tests[i].expected_result, has_action_key);
if (has_action_key) {
EXPECT_EQ(tests[i].expected_action_value, action_value);
new net::HttpResponseHeaders(headers));
DataReductionProxyInfo data_reduction_proxy_info;
- EXPECT_EQ(tests[i].expected_result,
- ParseHeadersAndSetProxyInfo(parsed, &data_reduction_proxy_info));
+ EXPECT_EQ(
+ tests[i].expected_result,
+ ParseHeadersAndSetProxyInfo(parsed.get(), &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,
new net::HttpResponseHeaders(headers));
DataReductionProxyInfo data_reduction_proxy_info;
- EXPECT_TRUE(ParseHeadersAndSetProxyInfo(parsed, &data_reduction_proxy_info));
+ EXPECT_TRUE(
+ ParseHeadersAndSetProxyInfo(parsed.get(), &data_reduction_proxy_info));
EXPECT_LE(60, data_reduction_proxy_info.bypass_duration.InSeconds());
EXPECT_GE(5 * 60, data_reduction_proxy_info.bypass_duration.InSeconds());
EXPECT_FALSE(data_reduction_proxy_info.bypass_all);
bool has_chrome_proxy_via_header, has_intermediary;
if (tests[i].ignore_intermediary) {
has_chrome_proxy_via_header =
- HasDataReductionProxyViaHeader(parsed, NULL);
+ HasDataReductionProxyViaHeader(parsed.get(), NULL);
}
else {
has_chrome_proxy_via_header =
- HasDataReductionProxyViaHeader(parsed, &has_intermediary);
+ HasDataReductionProxyViaHeader(parsed.get(), &has_intermediary);
}
EXPECT_EQ(tests[i].expected_result, has_chrome_proxy_via_header);
if (has_chrome_proxy_via_header && !tests[i].ignore_intermediary) {
scoped_refptr<net::HttpResponseHeaders> parsed(
new net::HttpResponseHeaders(headers));
DataReductionProxyInfo chrome_proxy_info;
- EXPECT_EQ(tests[i].expected_result,
- GetDataReductionProxyBypassType(parsed, &chrome_proxy_info));
+ EXPECT_EQ(
+ tests[i].expected_result,
+ GetDataReductionProxyBypassType(parsed.get(), &chrome_proxy_info));
}
}
std::string fingerprint;
bool fingerprint_exist = GetDataReductionProxyActionFingerprintChromeProxy(
- parsed, &fingerprint);
+ parsed.get(), &fingerprint);
EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist)
<< tests[i].label;
std::string fingerprint;
bool fingerprint_exist =
- GetDataReductionProxyActionFingerprintVia(parsed, &fingerprint);
+ GetDataReductionProxyActionFingerprintVia(parsed.get(), &fingerprint);
EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist)
<< tests[i].label;
new net::HttpResponseHeaders(headers));
std::string fingerprint;
- bool fingerprint_exist =
- GetDataReductionProxyActionFingerprintOtherHeaders(
- parsed, &fingerprint);
+ bool fingerprint_exist = GetDataReductionProxyActionFingerprintOtherHeaders(
+ parsed.get(), &fingerprint);
EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist)
<< tests[i].label;
std::string fingerprint;
bool fingerprint_exist =
- GetDataReductionProxyActionFingerprintContentLength(
- parsed, &fingerprint);
+ GetDataReductionProxyActionFingerprintContentLength(parsed.get(),
+ &fingerprint);
EXPECT_EQ(tests[i].expected_fingerprint_exist, fingerprint_exist)
<< tests[i].label;
new net::HttpResponseHeaders(headers));
std::vector<std::string> output_values;
- GetDataReductionProxyHeaderWithFingerprintRemoved(parsed, &output_values);
+ GetDataReductionProxyHeaderWithFingerprintRemoved(parsed.get(),
+ &output_values);
std::string output_values_string;
for (size_t j = 0; j < output_values.size(); ++j)