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. See |
204 // RequiresValidation for a description of the response_time parameter. | 211 // RequiresValidation for a description of the response_time parameter. |
205 base::TimeDelta GetFreshnessLifetime(const base::Time& response_time) const; | 212 base::TimeDelta GetFreshnessLifetime(base::Time response_time) const; |
206 | 213 |
207 // Returns the age of the response. See section 13.2.3 of RFC 2616. | 214 // 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. | 215 // local time at which the request that resulted in this response was made. |
209 base::TimeDelta GetCurrentAge(const base::Time& request_time, | 216 // |response_time| is the local time at which we received this response. |
210 const base::Time& response_time, | 217 base::Time GetFreshnessOrigin(base::Time request_time, |
211 const base::Time& current_time) const; | 218 base::Time response_time) const; |
212 | 219 |
213 // The following methods extract values from the response headers. If a | 220 // The following methods extract values from the response headers. If a |
214 // value is not present, then false is returned. Otherwise, true is returned | 221 // value is not present, then false is returned. Otherwise, true is returned |
215 // and the out param is assigned to the corresponding value. | 222 // and the out param is assigned to the corresponding value. |
216 bool GetMaxAgeValue(base::TimeDelta* value) const; | 223 bool GetMaxAgeValue(base::TimeDelta* value) const; |
217 bool GetAgeValue(base::TimeDelta* value) const; | 224 bool GetAgeValue(base::TimeDelta* value) const; |
218 bool GetDateValue(base::Time* value) const; | 225 bool GetDateValue(base::Time* value) const; |
219 bool GetLastModifiedValue(base::Time* value) const; | 226 bool GetLastModifiedValue(base::Time* value) const; |
220 bool GetExpiresValue(base::Time* value) const; | 227 bool GetExpiresValue(base::Time* value) const; |
221 | 228 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 406 |
400 // The parsed http version number (not normalized). | 407 // The parsed http version number (not normalized). |
401 HttpVersion parsed_http_version_; | 408 HttpVersion parsed_http_version_; |
402 | 409 |
403 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 410 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
404 }; | 411 }; |
405 | 412 |
406 } // namespace net | 413 } // namespace net |
407 | 414 |
408 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 415 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |