OLD | NEW |
---|---|
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 Loading... | |
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 std::string dummy; | |
125 if (headers->response_code() == net::HTTP_PROXY_AUTHENTICATION_REQUIRED | |
126 && !headers->EnumerateHeader(NULL, "Proxy-Authenticate", &dummy)) { | |
bengr
2014/06/05 17:26:24
Use headers->HasHeader("Proxy-Authenticate").
Not at Google. Contact bengr
2014/06/05 17:51:53
Done.
| |
127 return ProxyService::PROXY_407_BYPASS; | |
128 } | |
124 if (!IsDataReductionProxyResponse(headers) && | 129 if (!IsDataReductionProxyResponse(headers) && |
125 (headers->response_code() != net::HTTP_NOT_MODIFIED)) { | 130 (headers->response_code() != net::HTTP_NOT_MODIFIED)) { |
126 // A Via header might not be present in a 304. Since the goal of a 304 | 131 // A Via header might not be present in a 304. Since the goal of a 304 |
127 // response is to minimize information transfer, a sender in general | 132 // response is to minimize information transfer, a sender in general |
128 // should not generate representation metadata other than Cache-Control, | 133 // should not generate representation metadata other than Cache-Control, |
129 // Content-Location, Date, ETag, Expires, and Vary. | 134 // Content-Location, Date, ETag, Expires, and Vary. |
130 | 135 |
131 // The proxy Via header might also not be present in a 4xx response. | 136 // The proxy Via header might also not be present in a 4xx response. |
132 // Separate this case from other responses that are missing the header. | 137 // Separate this case from other responses that are missing the header. |
133 if (headers->response_code() >= net::HTTP_BAD_REQUEST && | 138 if (headers->response_code() >= net::HTTP_BAD_REQUEST && |
134 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) { | 139 headers->response_code() < net::HTTP_INTERNAL_SERVER_ERROR) { |
135 return ProxyService::PROXY_4XX_BYPASS; | 140 return ProxyService::PROXY_4XX_BYPASS; |
136 } | 141 } |
137 return ProxyService::MISSING_VIA_HEADER; | 142 return ProxyService::MISSING_VIA_HEADER; |
138 } | 143 } |
139 // There is no bypass event. | 144 // There is no bypass event. |
140 return ProxyService::BYPASS_EVENT_TYPE_MAX; | 145 return ProxyService::BYPASS_EVENT_TYPE_MAX; |
141 } | 146 } |
142 | 147 |
143 } // namespace data_reduction_proxy | 148 } // namespace data_reduction_proxy |
OLD | NEW |