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

Side by Side Diff: components/data_reduction_proxy/common/data_reduction_proxy_headers.cc

Issue 333113002: Move data reduction proxy to Chrome-Proxy header for authentication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flywheel-refactor-net-fake-a-redirect-response-headers-chrome-proxy-auth
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"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (data_reduction_proxy_info->bypass_duration < TimeDelta::FromMinutes(30)) 114 if (data_reduction_proxy_info->bypass_duration < TimeDelta::FromMinutes(30))
115 return ProxyService::SHORT_BYPASS; 115 return ProxyService::SHORT_BYPASS;
116 return ProxyService::LONG_BYPASS; 116 return ProxyService::LONG_BYPASS;
117 } 117 }
118 if (headers->response_code() == net::HTTP_INTERNAL_SERVER_ERROR || 118 if (headers->response_code() == net::HTTP_INTERNAL_SERVER_ERROR ||
119 headers->response_code() == net::HTTP_BAD_GATEWAY || 119 headers->response_code() == net::HTTP_BAD_GATEWAY ||
120 headers->response_code() == net::HTTP_SERVICE_UNAVAILABLE) { 120 headers->response_code() == net::HTTP_SERVICE_UNAVAILABLE) {
121 // Fall back if a 500, 502 or 503 is returned. 121 // Fall back if a 500, 502 or 503 is returned.
122 return ProxyService::INTERNAL_SERVER_ERROR_BYPASS; 122 return ProxyService::INTERNAL_SERVER_ERROR_BYPASS;
123 } 123 }
124 // TODO(kundaji): Bypass if Proxy-Authenticate header value cannot be
125 // interpreted by data reduction proxy.
126 if (headers->response_code() == net::HTTP_PROXY_AUTHENTICATION_REQUIRED &&
127 !headers->HasHeader("Proxy-Authenticate")) {
128 return ProxyService::MALFORMED_407_BYPASS;
129 }
130 if (!HasDataReductionProxyViaHeader(headers) && 124 if (!HasDataReductionProxyViaHeader(headers) &&
131 (headers->response_code() != net::HTTP_NOT_MODIFIED)) { 125 (headers->response_code() != net::HTTP_NOT_MODIFIED)) {
132 // A Via header might not be present in a 304. Since the goal of a 304 126 // A Via header might not be present in a 304. Since the goal of a 304
133 // response is to minimize information transfer, a sender in general 127 // response is to minimize information transfer, a sender in general
134 // should not generate representation metadata other than Cache-Control, 128 // should not generate representation metadata other than Cache-Control,
135 // Content-Location, Date, ETag, Expires, and Vary. 129 // Content-Location, Date, ETag, Expires, and Vary.
136 130
137 // The proxy Via header might also not be present in a 4xx response. 131 // The proxy Via header might also not be present in a 4xx response.
138 // Separate this case from other responses that are missing the header. 132 // Separate this case from other responses that are missing the header.
139 if (headers->response_code() >= net::HTTP_BAD_REQUEST && 133 if (headers->response_code() >= net::HTTP_BAD_REQUEST &&
140 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) { 134 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) {
141 return ProxyService::PROXY_4XX_BYPASS; 135 return ProxyService::PROXY_4XX_BYPASS;
142 } 136 }
143 return ProxyService::MISSING_VIA_HEADER; 137 return ProxyService::MISSING_VIA_HEADER;
144 } 138 }
145 // There is no bypass event. 139 // There is no bypass event.
146 return ProxyService::BYPASS_EVENT_TYPE_MAX; 140 return ProxyService::BYPASS_EVENT_TYPE_MAX;
147 } 141 }
148 142
149 } // namespace data_reduction_proxy 143 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698