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 the request was made that resulted in this response, which was | 196 // which we received this response. |
197 // received at response_time. | 197 base::Time GetFreshnessExpiry(base::Time request_time, |
198 bool RequiresValidation(const base::Time& request_time, | 198 base::Time response_time) const; |
199 const base::Time& response_time, | |
200 const base::Time& current_time) const; | |
201 | 199 |
202 // Returns the amount of time the server claims the response is fresh from | 200 // 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 | 201 // the time the response was generated. See section 13.2.4 of RFC 2616. |
204 // RequiresValidation for a description of the response_time parameter. | 202 // |response_time| is the local time at which we received this response. If |
205 base::TimeDelta GetFreshnessLifetime(const base::Time& response_time) const; | 203 // a finite (possibly zero) freshness lifetime exists, it is returned in the |
204 // output parameter |finite_freshness_lifetime|, and |was_finite| is set to | |
205 // false. If |was_finite| is true, the resource is fresh indefinitely, and | |
206 // |finite_freshness_lifetime| has an undefined value. | |
207 void GetFreshnessLifetime(base::Time response_time, | |
208 base::TimeDelta* finite_freshness_lifetime, | |
209 bool* was_finite) const; | |
206 | 210 |
207 // Returns the age of the response. See section 13.2.3 of RFC 2616. | 211 // 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. | 212 // local time at which the request that resulted in this response was made. |
209 base::TimeDelta GetCurrentAge(const base::Time& request_time, | 213 // |response_time| is the local time at which we received this response. |
210 const base::Time& response_time, | 214 base::Time GetFreshnessOrigin(base::Time request_time, |
211 const base::Time& current_time) const; | 215 base::Time response_time) const; |
212 | 216 |
rvargas (doing something else)
2014/02/06 22:39:58
How about adding a new method instead:
Time HttpR
gavinp
2014/02/07 15:59:18
I originally considered this second idea, of keepi
| |
213 // The following methods extract values from the response headers. If a | 217 // The following methods extract values from the response headers. If a |
214 // value is not present, then false is returned. Otherwise, true is returned | 218 // value is not present, then false is returned. Otherwise, true is returned |
215 // and the out param is assigned to the corresponding value. | 219 // and the out param is assigned to the corresponding value. |
216 bool GetMaxAgeValue(base::TimeDelta* value) const; | 220 bool GetMaxAgeValue(base::TimeDelta* value) const; |
217 bool GetAgeValue(base::TimeDelta* value) const; | 221 bool GetAgeValue(base::TimeDelta* value) const; |
218 bool GetDateValue(base::Time* value) const; | 222 bool GetDateValue(base::Time* value) const; |
219 bool GetLastModifiedValue(base::Time* value) const; | 223 bool GetLastModifiedValue(base::Time* value) const; |
220 bool GetExpiresValue(base::Time* value) const; | 224 bool GetExpiresValue(base::Time* value) const; |
221 | 225 |
222 // Extracts the time value of a particular header. This method looks for the | 226 // Extracts the time value of a particular header. This method looks for the |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 | 403 |
400 // The parsed http version number (not normalized). | 404 // The parsed http version number (not normalized). |
401 HttpVersion parsed_http_version_; | 405 HttpVersion parsed_http_version_; |
402 | 406 |
403 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 407 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
404 }; | 408 }; |
405 | 409 |
406 } // namespace net | 410 } // namespace net |
407 | 411 |
408 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 412 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |