Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: net/http/http_response_headers.h

Issue 2763393002: Remove stale-while-revalidate from net (Closed)
Patch Set: fixes Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 14 matching lines...) Expand all
25 class Time; 25 class Time;
26 class TimeDelta; 26 class TimeDelta;
27 class Value; 27 class Value;
28 } 28 }
29 29
30 namespace net { 30 namespace net {
31 31
32 class HttpByteRange; 32 class HttpByteRange;
33 class NetLogCaptureMode; 33 class NetLogCaptureMode;
34 34
35 enum ValidationType {
36 VALIDATION_NONE, // The resource is fresh.
37 VALIDATION_ASYNCHRONOUS, // The resource requires async revalidation.
38 VALIDATION_SYNCHRONOUS // The resource requires sync revalidation.
39 };
40
41 // HttpResponseHeaders: parses and holds HTTP response headers. 35 // HttpResponseHeaders: parses and holds HTTP response headers.
42 class NET_EXPORT HttpResponseHeaders 36 class NET_EXPORT HttpResponseHeaders
43 : public base::RefCountedThreadSafe<HttpResponseHeaders> { 37 : public base::RefCountedThreadSafe<HttpResponseHeaders> {
44 public: 38 public:
45 // Persist options. 39 // Persist options.
46 typedef int PersistOptions; 40 typedef int PersistOptions;
47 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. 41 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers.
48 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. 42 static const PersistOptions PERSIST_ALL = 0; // Parsed headers.
49 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; 43 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0;
50 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; 44 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1;
51 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; 45 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2;
52 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; 46 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3;
53 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; 47 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4;
54 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; 48 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5;
55 49
56 struct FreshnessLifetimes { 50 struct FreshnessLifetimes {
57 // How long the resource will be fresh for. 51 // How long the resource will be fresh for.
58 base::TimeDelta freshness; 52 base::TimeDelta freshness;
59 // How long after becoming not fresh that the resource will be stale but
60 // usable (if async revalidation is enabled).
61 base::TimeDelta staleness;
62 }; 53 };
63 54
64 static const char kContentRange[]; 55 static const char kContentRange[];
65 56
66 // Parses the given raw_headers. raw_headers should be formatted thus: 57 // Parses the given raw_headers. raw_headers should be formatted thus:
67 // includes the http status response line, each line is \0-terminated, and 58 // includes the http status response line, each line is \0-terminated, and
68 // it's terminated by an empty line (ie, 2 \0s in a row). 59 // it's terminated by an empty line (ie, 2 \0s in a row).
69 // (Note that line continuations should have already been joined; 60 // (Note that line continuations should have already been joined;
70 // see HttpUtil::AssembleRawHeaders) 61 // see HttpUtil::AssembleRawHeaders)
71 // 62 //
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 bool GetCharset(std::string* charset) const; 194 bool GetCharset(std::string* charset) const;
204 195
205 // Returns true if this response corresponds to a redirect. The target 196 // Returns true if this response corresponds to a redirect. The target
206 // location of the redirect is optionally returned if location is non-null. 197 // location of the redirect is optionally returned if location is non-null.
207 bool IsRedirect(std::string* location) const; 198 bool IsRedirect(std::string* location) const;
208 199
209 // Returns true if the HTTP response code passed in corresponds to a 200 // Returns true if the HTTP response code passed in corresponds to a
210 // redirect. 201 // redirect.
211 static bool IsRedirectResponseCode(int response_code); 202 static bool IsRedirectResponseCode(int response_code);
212 203
213 // Returns VALIDATION_NONE if the response can be reused without 204 // Returns false if the response can be reused without validation. true means
214 // validation. VALIDATION_ASYNCHRONOUS means the response can be re-used, but
215 // asynchronous revalidation must be performed. VALIDATION_SYNCHRONOUS means
216 // that the result cannot be reused without revalidation. 205 // that the result cannot be reused without revalidation.
217 // The result is relative to the current_time parameter, which is 206 // The result is relative to the current_time parameter, which is
218 // a parameter to support unit testing. The request_time parameter indicates 207 // a parameter to support unit testing. The request_time parameter indicates
219 // the time at which the request was made that resulted in this response, 208 // the time at which the request was made that resulted in this response,
220 // which was received at response_time. 209 // which was received at response_time.
221 ValidationType RequiresValidation(const base::Time& request_time, 210 bool RequiresValidation(const base::Time& request_time,
222 const base::Time& response_time, 211 const base::Time& response_time,
223 const base::Time& current_time) const; 212 const base::Time& current_time) const;
224 213
225 // Calculates the amount of time the server claims the response is fresh from 214 // Calculates the amount of time the server claims the response is fresh from
226 // the time the response was generated. See section 13.2.4 of RFC 2616. See 215 // the time the response was generated. See section 13.2.4 of RFC 2616. See
227 // RequiresValidation for a description of the response_time parameter. See 216 // RequiresValidation for a description of the response_time parameter. See
228 // the definition of FreshnessLifetimes above for the meaning of the return 217 // the definition of FreshnessLifetimes above for the meaning of the return
229 // value. See RFC 5861 section 3 for the definition of 218 // value.
230 // stale-while-revalidate.
231 FreshnessLifetimes GetFreshnessLifetimes( 219 FreshnessLifetimes GetFreshnessLifetimes(
232 const base::Time& response_time) const; 220 const base::Time& response_time) const;
233 221
234 // Returns the age of the response. See section 13.2.3 of RFC 2616. 222 // Returns the age of the response. See section 13.2.3 of RFC 2616.
235 // See RequiresValidation for a description of this method's parameters. 223 // See RequiresValidation for a description of this method's parameters.
236 base::TimeDelta GetCurrentAge(const base::Time& request_time, 224 base::TimeDelta GetCurrentAge(const base::Time& request_time,
237 const base::Time& response_time, 225 const base::Time& response_time,
238 const base::Time& current_time) const; 226 const base::Time& current_time) const;
239 227
240 // The following methods extract values from the response headers. If a 228 // The following methods extract values from the response headers. If a
241 // value is not present, or is invalid, then false is returned. Otherwise, 229 // value is not present, or is invalid, then false is returned. Otherwise,
242 // true is returned and the out param is assigned to the corresponding value. 230 // true is returned and the out param is assigned to the corresponding value.
243 bool GetMaxAgeValue(base::TimeDelta* value) const; 231 bool GetMaxAgeValue(base::TimeDelta* value) const;
244 bool GetAgeValue(base::TimeDelta* value) const; 232 bool GetAgeValue(base::TimeDelta* value) const;
245 bool GetDateValue(base::Time* value) const; 233 bool GetDateValue(base::Time* value) const;
246 bool GetLastModifiedValue(base::Time* value) const; 234 bool GetLastModifiedValue(base::Time* value) const;
247 bool GetExpiresValue(base::Time* value) const; 235 bool GetExpiresValue(base::Time* value) const;
248 bool GetStaleWhileRevalidateValue(base::TimeDelta* value) const;
249 236
250 // Extracts the time value of a particular header. This method looks for the 237 // Extracts the time value of a particular header. This method looks for the
251 // first matching header value and parses its value as a HTTP-date. 238 // first matching header value and parses its value as a HTTP-date.
252 bool GetTimeValuedHeader(const std::string& name, base::Time* result) const; 239 bool GetTimeValuedHeader(const std::string& name, base::Time* result) const;
253 240
254 // Determines if this response indicates a keep-alive connection. 241 // Determines if this response indicates a keep-alive connection.
255 bool IsKeepAlive() const; 242 bool IsKeepAlive() const;
256 243
257 // Returns true if this response has a strong etag or last-modified header. 244 // Returns true if this response has a strong etag or last-modified header.
258 // See section 13.3.3 of RFC 2616. 245 // See section 13.3.3 of RFC 2616.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 394
408 // The normalized http version (consistent with what GetStatusLine() returns). 395 // The normalized http version (consistent with what GetStatusLine() returns).
409 HttpVersion http_version_; 396 HttpVersion http_version_;
410 397
411 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); 398 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders);
412 }; 399 };
413 400
414 } // namespace net 401 } // namespace net
415 402
416 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ 403 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_
OLDNEW
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698