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

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings.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: chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc
index c8aa7c9c53e782c0c66160433e38d7038d850c76..7e3af65c07672c6a7dd4e8eada41c090f552cee7 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.cc
@@ -209,12 +209,32 @@ bool DataReductionProxySettings::IsPreconnectHintingAllowed() {
// static
bool DataReductionProxySettings::WasFetchedViaProxy(
- const net::HttpResponseHeaders* headers) {
- const char kChromeProxyViaValue[] = "1.1 Chrome Compression Proxy";
+ const net::HttpResponseHeaders* response_headers) {
+ if (!response_headers) {
+ return false;
+ }
+
+ const size_t kVersionSize = 4;
+ const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy";
mef 2014/02/07 20:33:25 Any particular reason to skip version? Also, I t
bengr 2014/02/07 23:55:36 The version is the HTTP version from the origin, w
mef 2014/02/12 18:12:18 Are you sure? From this comment in rfc2616 it seem
bengr 2014/02/12 21:14:00 It is always the protocol used for the response fr
+ size_t value_len = strlen(kDataReductionProxyViaValue);
void* iter = NULL;
std::string value;
- while (headers->EnumerateHeader(&iter, "via", &value))
- if (value == kChromeProxyViaValue) return true;
+
+ // 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;
}

Powered by Google App Engine
This is Rietveld 408576698