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

Unified Diff: net/http/http_network_transaction.cc

Issue 156373002: Support for new data reduction proxy via header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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: net/http/http_network_transaction.cc
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 96817e2b14fa2c1bb96ff827015943e96c6aedf0..6561a0aad23e47ac9dbc210888868f1247cd0b79 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -126,19 +126,28 @@ bool IsChromeProxyResponse(const net::HttpResponseHeaders* response_headers) {
if (!response_headers) {
return false;
}
- const char kDataReductionProxyViaValue[] = "1.1 Chrome Compression Proxy";
+
+ const size_t kVersionSize = 4;
+ const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy";
size_t value_len = strlen(kDataReductionProxyViaValue);
void* iter = NULL;
- std::string temp;
- while (response_headers->EnumerateHeader(&iter, "Via", &temp)) {
- std::string::const_iterator it =
- std::search(temp.begin(), temp.end(),
- kDataReductionProxyViaValue,
- kDataReductionProxyViaValue + value_len,
- base::CaseInsensitiveCompareASCII<char>());
- if (it != temp.end())
+ std::string value;
+
+ // Case-sensitive comparison. Assumes the received protocol and the space
+ // following it are always |kVersionSize| characters. E.g.,
+ // 'Via: 1.1 Chrome-Compression-Proxy'
+ while (response_headers->EnumerateHeader(&iter, "via", &value)) {
+ if (!value.compare(kVersionSize, value_len, kDataReductionProxyViaValue))
return true;
}
+
+ // TODO(bengr): Remove deprecated header value.
+ const char kDeprecatedDataReductionProxyViaValue[] =
+ "1.1 Chrome Compression Proxy";
+ iter = NULL;
+ while (response_headers->EnumerateHeader(&iter, "via", &value))
+ if (value == kDeprecatedDataReductionProxyViaValue) return true;
+
return false;
}
#endif

Powered by Google App Engine
This is Rietveld 408576698