OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_RESPONSE_HEADERS_H_ | 5 #ifndef NET_HTTP_RESPONSE_HEADERS_H_ |
6 #define NET_HTTP_RESPONSE_HEADERS_H_ | 6 #define NET_HTTP_RESPONSE_HEADERS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 // us to access the raw byte sequence as sent by a web server. In any case, | 37 // us to access the raw byte sequence as sent by a web server. In any case, |
38 // HttpResponseHeaders does not perform any encoding changes on the input. | 38 // HttpResponseHeaders does not perform any encoding changes on the input. |
39 // | 39 // |
40 explicit HttpResponseHeaders(const std::string& raw_headers); | 40 explicit HttpResponseHeaders(const std::string& raw_headers); |
41 | 41 |
42 // Initializes from the representation stored in the given pickle. The data | 42 // Initializes from the representation stored in the given pickle. The data |
43 // for this object is found relative to the given pickle_iter, which should | 43 // for this object is found relative to the given pickle_iter, which should |
44 // be passed to the pickle's various Read* methods. | 44 // be passed to the pickle's various Read* methods. |
45 HttpResponseHeaders(const Pickle& pickle, void** pickle_iter); | 45 HttpResponseHeaders(const Pickle& pickle, void** pickle_iter); |
46 | 46 |
47 // Appends a representation of this object to the given pickle. If the | 47 // Persist options. |
48 // for_cache argument is true, then non-cacheable headers will be pruned from | 48 typedef int PersistOptions; |
49 // the persisted version of the response headers. | 49 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. |
50 void Persist(Pickle* pickle, bool for_cache); | 50 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. |
| 51 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; |
| 52 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; |
| 53 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; |
| 54 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; |
| 55 |
| 56 // Appends a representation of this object to the given pickle. |
| 57 // The options argument can be a combination of PersistOptions. |
| 58 void Persist(Pickle* pickle, PersistOptions options); |
51 | 59 |
52 // Performs header merging as described in 13.5.3 of RFC 2616. | 60 // Performs header merging as described in 13.5.3 of RFC 2616. |
53 void Update(const HttpResponseHeaders& new_headers); | 61 void Update(const HttpResponseHeaders& new_headers); |
54 | 62 |
55 // Creates a normalized header string. The output will be formatted exactly | 63 // Creates a normalized header string. The output will be formatted exactly |
56 // like so: | 64 // like so: |
57 // HTTP/<version> <status_code> <status_text>\n | 65 // HTTP/<version> <status_code> <status_text>\n |
58 // [<header-name>: <header-values>\n]* | 66 // [<header-name>: <header-values>\n]* |
59 // meaning, each line is \n-terminated, and there is no extra whitespace | 67 // meaning, each line is \n-terminated, and there is no extra whitespace |
60 // beyond the single space separators shown (of course, values can contain | 68 // beyond the single space separators shown (of course, values can contain |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 std::string::const_iterator value_end); | 243 std::string::const_iterator value_end); |
236 | 244 |
237 // Add to parsed_ given the fields of a ParsedHeader object. | 245 // Add to parsed_ given the fields of a ParsedHeader object. |
238 void AddToParsed(std::string::const_iterator name_begin, | 246 void AddToParsed(std::string::const_iterator name_begin, |
239 std::string::const_iterator name_end, | 247 std::string::const_iterator name_end, |
240 std::string::const_iterator value_begin, | 248 std::string::const_iterator value_begin, |
241 std::string::const_iterator value_end); | 249 std::string::const_iterator value_end); |
242 | 250 |
243 typedef base::hash_set<std::string> HeaderSet; | 251 typedef base::hash_set<std::string> HeaderSet; |
244 | 252 |
245 // Returns the values from any 'cache-control: no-cache="foo,bar"' headers as | 253 // Adds the values from any 'cache-control: no-cache="foo,bar"' headers. |
246 // well as other known-to-be-transient header names. The header names are | 254 void AddNonCacheableHeaders(HeaderSet* header_names) const; |
247 // all lowercase to support fast lookup. | 255 |
248 void GetTransientHeaders(HeaderSet* header_names) const; | 256 // Adds the set of header names that contain cookie values. |
| 257 static void AddSensitiveHeaders(HeaderSet* header_names); |
| 258 |
| 259 // Adds the set of rfc2616 hop-by-hop response headers. |
| 260 static void AddHopByHopHeaders(HeaderSet* header_names); |
| 261 |
| 262 // Adds the set of challenge response headers. |
| 263 static void AddChallengeHeaders(HeaderSet* header_names); |
| 264 |
| 265 // Adds the set of cookie response headers. |
| 266 static void AddCookieHeaders(HeaderSet* header_names); |
249 | 267 |
250 // The members of this structure point into raw_headers_. | 268 // The members of this structure point into raw_headers_. |
251 struct ParsedHeader { | 269 struct ParsedHeader { |
252 std::string::const_iterator name_begin; | 270 std::string::const_iterator name_begin; |
253 std::string::const_iterator name_end; | 271 std::string::const_iterator name_end; |
254 std::string::const_iterator value_begin; | 272 std::string::const_iterator value_begin; |
255 std::string::const_iterator value_end; | 273 std::string::const_iterator value_end; |
256 | 274 |
257 // A header "continuation" contains only a subsequent value for the | 275 // A header "continuation" contains only a subsequent value for the |
258 // preceding header. (Header values are comma separated.) | 276 // preceding header. (Header values are comma separated.) |
(...skipping 21 matching lines...) Expand all Loading... |
280 | 298 |
281 // The parsed http version number (not normalized). | 299 // The parsed http version number (not normalized). |
282 HttpVersion parsed_http_version_; | 300 HttpVersion parsed_http_version_; |
283 | 301 |
284 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 302 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
285 }; | 303 }; |
286 | 304 |
287 } // namespace net | 305 } // namespace net |
288 | 306 |
289 #endif // NET_HTTP_RESPONSE_HEADERS_H_ | 307 #endif // NET_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |