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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return dict; 119 return dict;
120 } 120 }
121 121
122 #if defined(SPDY_PROXY_AUTH_ORIGIN) 122 #if defined(SPDY_PROXY_AUTH_ORIGIN)
123 // Returns true if |response_headers| contains the data reduction proxy Via 123 // Returns true if |response_headers| contains the data reduction proxy Via
124 // header value. 124 // header value.
125 bool IsChromeProxyResponse(const net::HttpResponseHeaders* response_headers) { 125 bool IsChromeProxyResponse(const net::HttpResponseHeaders* response_headers) {
126 if (!response_headers) { 126 if (!response_headers) {
127 return false; 127 return false;
128 } 128 }
129 const char kDataReductionProxyViaValue[] = "1.1 Chrome Compression Proxy"; 129
130 const size_t kVersionSize = 4;
131 const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy";
130 size_t value_len = strlen(kDataReductionProxyViaValue); 132 size_t value_len = strlen(kDataReductionProxyViaValue);
131 void* iter = NULL; 133 void* iter = NULL;
132 std::string temp; 134 std::string value;
133 while (response_headers->EnumerateHeader(&iter, "Via", &temp)) { 135
134 std::string::const_iterator it = 136 // Case-sensitive comparison. Assumes the received protocol and the space
135 std::search(temp.begin(), temp.end(), 137 // following it are always |kVersionSize| characters. E.g.,
136 kDataReductionProxyViaValue, 138 // 'Via: 1.1 Chrome-Compression-Proxy'
137 kDataReductionProxyViaValue + value_len, 139 while (response_headers->EnumerateHeader(&iter, "via", &value)) {
138 base::CaseInsensitiveCompareASCII<char>()); 140 if (!value.compare(kVersionSize, value_len, kDataReductionProxyViaValue))
139 if (it != temp.end())
140 return true; 141 return true;
141 } 142 }
143
144 // TODO(bengr): Remove deprecated header value.
145 const char kDeprecatedDataReductionProxyViaValue[] =
146 "1.1 Chrome Compression Proxy";
147 iter = NULL;
148 while (response_headers->EnumerateHeader(&iter, "via", &value))
149 if (value == kDeprecatedDataReductionProxyViaValue) return true;
150
142 return false; 151 return false;
143 } 152 }
144 #endif 153 #endif
145 154
146 } // namespace 155 } // namespace
147 156
148 //----------------------------------------------------------------------------- 157 //-----------------------------------------------------------------------------
149 158
150 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority, 159 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority,
151 HttpNetworkSession* session) 160 HttpNetworkSession* session)
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1656 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1648 state); 1657 state);
1649 break; 1658 break;
1650 } 1659 }
1651 return description; 1660 return description;
1652 } 1661 }
1653 1662
1654 #undef STATE_CASE 1663 #undef STATE_CASE
1655 1664
1656 } // namespace net 1665 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698