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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" 5 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "net/http/http_response_headers.h" 13 #include "net/http/http_response_headers.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 #include "net/proxy/proxy_service.h" 15 #include "net/proxy/proxy_service.h"
16 16
17 using base::StringPiece; 17 using base::StringPiece;
18 using base::TimeDelta; 18 using base::TimeDelta;
19 using net::ProxyService; 19 using net::ProxyService;
20 20
21 namespace data_reduction_proxy { 21 namespace data_reduction_proxy {
22 22
23 const char* kDataReductionProxyViaValues[] = {"Chrome-Compression-Proxy", 23 const char* kDataReductionProxyViaValues[] = {"Chrome-Compression-Proxy",
24 "Chrome Compression Proxy"}; 24 "Chrome Compression Proxy"};
25 25
26 bool GetDataReductionProxyActionValue(
27 const net::HttpResponseHeaders* headers,
28 const std::string& action_prefix,
29 std::string* action_value) {
30 void* iter = NULL;
31 std::string value;
32 std::string name = "chrome-proxy";
bolian 2014/07/14 19:23:58 inline this in the func call. (Don't we have cons
xingx 2014/07/14 21:37:16 Acknowledged.
bolian 2014/07/14 22:42:43 ?
xingx 2014/07/14 22:51:08 Copied code from below.
33
34 while (headers->EnumerateHeader(&iter, name, &value)) {
35 if (value.size() > action_prefix.size()) {
bolian 2014/07/14 19:23:59 >=? add a test case for that.
xingx 2014/07/14 21:37:16 Done. It should be ">=" to get the empty value, b
36 if (LowerCaseEqualsASCII(value.begin(),
37 value.begin() + action_prefix.size(),
38 action_prefix.c_str())) {
39 *action_value = value.substr(action_prefix.size());
bengr 2014/07/14 18:27:13 Before the loop, either DCHECK that action_value i
xingx 2014/07/14 21:37:16 Done.
40 return true;
41 }
42 }
43 }
44 return false;
45 }
46
26 bool GetDataReductionProxyBypassDuration( 47 bool GetDataReductionProxyBypassDuration(
27 const net::HttpResponseHeaders* headers, 48 const net::HttpResponseHeaders* headers,
28 const std::string& action_prefix, 49 const std::string& action_prefix,
29 base::TimeDelta* duration) { 50 base::TimeDelta* duration) {
30 void* iter = NULL; 51 void* iter = NULL;
31 std::string value; 52 std::string value;
32 std::string name = "chrome-proxy"; 53 std::string name = "chrome-proxy";
33 54
34 while (headers->EnumerateHeader(&iter, name, &value)) { 55 while (headers->EnumerateHeader(&iter, name, &value)) {
35 if (value.size() > action_prefix.size()) { 56 if (value.size() > action_prefix.size()) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) { 158 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) {
138 return ProxyService::PROXY_4XX_BYPASS; 159 return ProxyService::PROXY_4XX_BYPASS;
139 } 160 }
140 return ProxyService::MISSING_VIA_HEADER; 161 return ProxyService::MISSING_VIA_HEADER;
141 } 162 }
142 // There is no bypass event. 163 // There is no bypass event.
143 return ProxyService::BYPASS_EVENT_TYPE_MAX; 164 return ProxyService::BYPASS_EVENT_TYPE_MAX;
144 } 165 }
145 166
146 } // namespace data_reduction_proxy 167 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698