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

Unified Diff: components/data_reduction_proxy/common/data_reduction_proxy_headers.cc

Issue 387353003: Modify data_reduction_proxy_header to support tamper detection logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@work
Patch Set: Created 6 years, 5 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
Index: components/data_reduction_proxy/common/data_reduction_proxy_headers.cc
diff --git a/components/data_reduction_proxy/common/data_reduction_proxy_headers.cc b/components/data_reduction_proxy/common/data_reduction_proxy_headers.cc
index e48afc366876e3aed082e133548044b45713a1f2..4a50ad2f8749be342faa7f37d6ecf0d523b962e3 100644
--- a/components/data_reduction_proxy/common/data_reduction_proxy_headers.cc
+++ b/components/data_reduction_proxy/common/data_reduction_proxy_headers.cc
@@ -23,10 +23,35 @@ namespace data_reduction_proxy {
const char* kDataReductionProxyViaValues[] = {"Chrome-Compression-Proxy",
"Chrome Compression Proxy"};
+bool GetDataReductionProxyActionValue(
+ const net::HttpResponseHeaders* headers,
+ const std::string& action_prefix,
+ std::string* action_value) {
+ DCHECK(action_prefix.size());
+ void* iter = NULL;
+ std::string value;
+ std::string name = "chrome-proxy";
+
+ while (headers->EnumerateHeader(&iter, name, &value)) {
+ if (value.size() > action_prefix.size()) {
+ if (LowerCaseEqualsASCII(value.begin(),
+ value.begin() + action_prefix.size(),
+ action_prefix.c_str()) &&
+ value[action_prefix.size()] == '=') {
+ if (action_value)
+ *action_value = value.substr(action_prefix.size() + 1);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
bool GetDataReductionProxyBypassDuration(
bolian 2014/07/14 22:42:43 why doesn't this one call GetDataReductionProxyAct
xingx 2014/07/14 22:51:08 Need to discuss with Ben: my function (above) retu
const net::HttpResponseHeaders* headers,
const std::string& action_prefix,
base::TimeDelta* duration) {
+ DCHECK(action_prefix.size());
void* iter = NULL;
std::string value;
std::string name = "chrome-proxy";
@@ -35,10 +60,12 @@ bool GetDataReductionProxyBypassDuration(
if (value.size() > action_prefix.size()) {
if (LowerCaseEqualsASCII(value.begin(),
value.begin() + action_prefix.size(),
- action_prefix.c_str())) {
+ action_prefix.c_str()) &&
+ value[action_prefix.size()] == '=') {
int64 seconds;
if (!base::StringToInt64(
- StringPiece(value.begin() + action_prefix.size(), value.end()),
+ StringPiece(value.begin() + action_prefix.size() + 1,
+ value.end()),
&seconds) || seconds < 0) {
continue; // In case there is a well formed instruction.
}
@@ -66,14 +93,14 @@ bool GetDataReductionProxyInfo(const net::HttpResponseHeaders* headers,
// 'block' takes precedence over 'bypass', so look for it first.
// TODO(bengr): Reduce checks for 'block' and 'bypass' to a single loop.
if (GetDataReductionProxyBypassDuration(
- headers, "block=", &proxy_info->bypass_duration)) {
+ headers, "block", &proxy_info->bypass_duration)) {
proxy_info->bypass_all = true;
return true;
}
// Next, look for 'bypass'.
if (GetDataReductionProxyBypassDuration(
- headers, "bypass=", &proxy_info->bypass_duration)) {
+ headers, "bypass", &proxy_info->bypass_duration)) {
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698