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