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