OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 5 #ifndef NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
6 #define NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 6 #define NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 bool GetCharset(std::string* charset) const; | 183 bool GetCharset(std::string* charset) const; |
184 | 184 |
185 // Returns true if this response corresponds to a redirect. The target | 185 // Returns true if this response corresponds to a redirect. The target |
186 // location of the redirect is optionally returned if location is non-null. | 186 // location of the redirect is optionally returned if location is non-null. |
187 bool IsRedirect(std::string* location) const; | 187 bool IsRedirect(std::string* location) const; |
188 | 188 |
189 // Returns true if the HTTP response code passed in corresponds to a | 189 // Returns true if the HTTP response code passed in corresponds to a |
190 // redirect. | 190 // redirect. |
191 static bool IsRedirectResponseCode(int response_code); | 191 static bool IsRedirectResponseCode(int response_code); |
192 | 192 |
193 // Returns true if the response cannot be reused without validation. The | 193 // Returns the time from which this resource can no longer be reused without |
194 // result is relative to the current_time parameter, which is a parameter to | 194 // validation. |request_time| is the local time at which the request that |
195 // support unit testing. The request_time parameter indicates the time at | 195 // resulted in this response was made. |response_time| is the local time at |
| 196 // which we received this response. |
| 197 base::Time GetFreshnessExpiry(base::Time request_time, |
| 198 base::Time response_time) const; |
| 199 |
| 200 // Returns true if the response cannot be reused without validation. The |
| 201 // result is relative to the |current_time| parameter, which is a parameter to |
| 202 // support unit testing. The |request_time| parameter indicates the time at |
196 // which the request was made that resulted in this response, which was | 203 // which the request was made that resulted in this response, which was |
197 // received at response_time. | 204 // received at |response_time|. |
198 bool RequiresValidation(const base::Time& request_time, | 205 bool RequiresValidation(base::Time request_time, |
199 const base::Time& response_time, | 206 base::Time response_time, |
200 const base::Time& current_time) const; | 207 base::Time current_time) const; |
201 | 208 |
202 // Returns the amount of time the server claims the response is fresh from | 209 // Returns the amount of time the server claims the response is fresh from |
203 // the time the response was generated. See section 13.2.4 of RFC 2616. See | 210 // the time the response was generated. See section 13.2.4 of RFC 2616. |
204 // RequiresValidation for a description of the response_time parameter. | 211 // |response_time| is the local time at which we received this response. If |
205 base::TimeDelta GetFreshnessLifetime(const base::Time& response_time) const; | 212 // a finite (possibly zero) freshness lifetime exists, it is returned in the |
| 213 // output parameter |finite_freshness_lifetime|, and |was_finite| is set to |
| 214 // false. If |was_finite| is true, the resource is fresh indefinitely, and |
| 215 // |finite_freshness_lifetime| has an undefined value. |
| 216 void GetFreshnessLifetime(base::Time response_time, |
| 217 base::TimeDelta* finite_freshness_lifetime, |
| 218 bool* was_finite) const; |
206 | 219 |
207 // Returns the age of the response. See section 13.2.3 of RFC 2616. | 220 // Returns the time at which this resource had age zero. |request_time| is the |
208 // See RequiresValidation for a description of this method's parameters. | 221 // local time at which the request that resulted in this response was made. |
209 base::TimeDelta GetCurrentAge(const base::Time& request_time, | 222 // |response_time| is the local time at which we received this response. |
210 const base::Time& response_time, | 223 base::Time GetFreshnessOrigin(base::Time request_time, |
211 const base::Time& current_time) const; | 224 base::Time response_time) const; |
212 | 225 |
213 // The following methods extract values from the response headers. If a | 226 // The following methods extract values from the response headers. If a |
214 // value is not present, then false is returned. Otherwise, true is returned | 227 // value is not present, then false is returned. Otherwise, true is returned |
215 // and the out param is assigned to the corresponding value. | 228 // and the out param is assigned to the corresponding value. |
216 bool GetMaxAgeValue(base::TimeDelta* value) const; | 229 bool GetMaxAgeValue(base::TimeDelta* value) const; |
217 bool GetAgeValue(base::TimeDelta* value) const; | 230 bool GetAgeValue(base::TimeDelta* value) const; |
218 bool GetDateValue(base::Time* value) const; | 231 bool GetDateValue(base::Time* value) const; |
219 bool GetLastModifiedValue(base::Time* value) const; | 232 bool GetLastModifiedValue(base::Time* value) const; |
220 bool GetExpiresValue(base::Time* value) const; | 233 bool GetExpiresValue(base::Time* value) const; |
221 | 234 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 412 |
400 // The parsed http version number (not normalized). | 413 // The parsed http version number (not normalized). |
401 HttpVersion parsed_http_version_; | 414 HttpVersion parsed_http_version_; |
402 | 415 |
403 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 416 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
404 }; | 417 }; |
405 | 418 |
406 } // namespace net | 419 } // namespace net |
407 | 420 |
408 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 421 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |