Chromium Code Reviews| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 17 #include "net/http/http_version.h" | 17 #include "net/http/http_version.h" |
| 18 | 18 |
| 19 class Pickle; | 19 class Pickle; |
| 20 class PickleIterator; | 20 class PickleIterator; |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class Time; | 23 class Time; |
| 24 class TimeDelta; | 24 class TimeDelta; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 | 28 |
| 29 class HttpByteRange; | |
| 30 | |
| 29 // HttpResponseHeaders: parses and holds HTTP response headers. | 31 // HttpResponseHeaders: parses and holds HTTP response headers. |
| 30 class NET_EXPORT HttpResponseHeaders | 32 class NET_EXPORT HttpResponseHeaders |
| 31 : public base::RefCountedThreadSafe<HttpResponseHeaders> { | 33 : public base::RefCountedThreadSafe<HttpResponseHeaders> { |
| 32 public: | 34 public: |
| 33 // Persist options. | 35 // Persist options. |
| 34 typedef int PersistOptions; | 36 typedef int PersistOptions; |
| 35 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. | 37 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. |
| 36 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. | 38 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. |
| 37 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; | 39 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; |
| 38 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; | 40 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // EOL termination, just [<header-name>: <header-values>] | 78 // EOL termination, just [<header-name>: <header-values>] |
| 77 // If a header with the same name is already stored, the two headers are not | 79 // If a header with the same name is already stored, the two headers are not |
| 78 // merged together by this method; the one provided is simply put at the | 80 // merged together by this method; the one provided is simply put at the |
| 79 // end of the list. | 81 // end of the list. |
| 80 void AddHeader(const std::string& header); | 82 void AddHeader(const std::string& header); |
| 81 | 83 |
| 82 // Replaces the current status line with the provided one (|new_status| should | 84 // Replaces the current status line with the provided one (|new_status| should |
| 83 // not have any EOL). | 85 // not have any EOL). |
| 84 void ReplaceStatusLine(const std::string& new_status); | 86 void ReplaceStatusLine(const std::string& new_status); |
| 85 | 87 |
| 88 // Updates headers (Content-Length and Content-Range) in the |headers| to | |
| 89 // include the right content length and range for |byte_range|. This also | |
| 90 // updates HTTP status line if |replace_status_line| is true. It is not valid | |
| 91 // to give invalid |byte_range|. | |
|
mmenke
2014/03/06 18:18:48
This also doesn't work for suffix byte ranges, or
rvargas (doing something else)
2014/03/06 19:24:00
Maybe the right message is that byte_range should
kinuko
2014/03/07 05:05:14
I tried to improve the comment... I'm still learni
| |
| 92 void UpdateWithNewRange(const HttpByteRange& byte_range, | |
| 93 int64 resource_size, | |
| 94 bool replace_status_line); | |
| 95 | |
| 86 // Creates a normalized header string. The output will be formatted exactly | 96 // Creates a normalized header string. The output will be formatted exactly |
| 87 // like so: | 97 // like so: |
| 88 // HTTP/<version> <status_code> <status_text>\n | 98 // HTTP/<version> <status_code> <status_text>\n |
| 89 // [<header-name>: <header-values>\n]* | 99 // [<header-name>: <header-values>\n]* |
| 90 // meaning, each line is \n-terminated, and there is no extra whitespace | 100 // meaning, each line is \n-terminated, and there is no extra whitespace |
| 91 // beyond the single space separators shown (of course, values can contain | 101 // beyond the single space separators shown (of course, values can contain |
| 92 // whitespace within them). If a given header-name appears more than once | 102 // whitespace within them). If a given header-name appears more than once |
| 93 // in the set of headers, they are combined into a single line like so: | 103 // in the set of headers, they are combined into a single line like so: |
| 94 // <header-name>: <header-value1>, <header-value2>, ...<header-valueN>\n | 104 // <header-name>: <header-value1>, <header-value2>, ...<header-valueN>\n |
| 95 // | 105 // |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 | 412 |
| 403 // The parsed http version number (not normalized). | 413 // The parsed http version number (not normalized). |
| 404 HttpVersion parsed_http_version_; | 414 HttpVersion parsed_http_version_; |
| 405 | 415 |
| 406 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 416 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
| 407 }; | 417 }; |
| 408 | 418 |
| 409 } // namespace net | 419 } // namespace net |
| 410 | 420 |
| 411 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 421 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
| OLD | NEW |