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

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

Issue 2771413004: DRP: Add check that ECT header is present when CPAT header is present. (Closed)
Patch Set: megjablon comments Created 3 years, 9 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 | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc » ('j') | 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_network_delegate.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
index c21bf44cb429319c931cdd0f8c195080fd7b04d6..b36fd93d5ee321020b87c31dd20c128ac4ca1e5c 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
@@ -115,6 +115,21 @@ int64_t EstimateOriginalReceivedBytes(const net::URLRequest& request) {
util::CalculateEffectiveOCL(request);
}
+// Verifies that the chrome proxy related request headers are set correctly.
+// |via_chrome_proxy| is true if the request is being fetched via Chrome Data
+// Saver proxy.
+void VerifyHttpRequestHeaders(bool via_chrome_proxy,
+ const net::HttpRequestHeaders& headers) {
+ if (via_chrome_proxy) {
+ DCHECK(headers.HasHeader(chrome_proxy_header()));
+ DCHECK(headers.HasHeader(chrome_proxy_ect_header()));
+ } else {
+ DCHECK(!headers.HasHeader(chrome_proxy_header()));
+ DCHECK(!headers.HasHeader(chrome_proxy_accept_transform_header()));
+ DCHECK(!headers.HasHeader(chrome_proxy_ect_header()));
+ }
+}
+
} // namespace
DataReductionProxyNetworkDelegate::DataReductionProxyNetworkDelegate(
@@ -220,6 +235,7 @@ void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal(
DataReductionProxyData::GetDataAndCreateIfNecessary(request);
if (data)
data->set_used_data_reduction_proxy(true);
+ VerifyHttpRequestHeaders(false, *headers);
return;
}
@@ -246,6 +262,7 @@ void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal(
lofi_decider->RemoveAcceptTransformHeader(headers);
}
RemoveChromeProxyECTHeader(headers);
+ VerifyHttpRequestHeaders(false, *headers);
return;
}
@@ -282,6 +299,7 @@ void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal(
data_reduction_proxy_request_options_->AddRequestHeader(headers);
if (lofi_decider)
lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(headers);
+ VerifyHttpRequestHeaders(true, *headers);
}
void DataReductionProxyNetworkDelegate::OnBeforeRedirectInternal(
@@ -514,7 +532,8 @@ void DataReductionProxyNetworkDelegate::MaybeAddChromeProxyECTHeader(
DCHECK(!request.url().SchemeIsCryptographic());
DCHECK(request.url().SchemeIsHTTPOrHTTPS());
- DCHECK(!request_headers->HasHeader(chrome_proxy_ect_header()));
+ if (request_headers->HasHeader(chrome_proxy_ect_header()))
+ request_headers->RemoveHeader(chrome_proxy_ect_header());
if (request.context()->network_quality_estimator()) {
net::EffectiveConnectionType type = request.context()
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698