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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // Updates headers (Content-Length and Content-Range) in the |headers| to | 113 // Updates headers (Content-Length and Content-Range) in the |headers| to |
114 // include the right content length and range for |byte_range|. This also | 114 // include the right content length and range for |byte_range|. This also |
115 // updates HTTP status line if |replace_status_line| is true. | 115 // updates HTTP status line if |replace_status_line| is true. |
116 // |byte_range| must have a valid, bounded range (i.e. coming from a valid | 116 // |byte_range| must have a valid, bounded range (i.e. coming from a valid |
117 // response or should be usable for a response). | 117 // response or should be usable for a response). |
118 void UpdateWithNewRange(const HttpByteRange& byte_range, | 118 void UpdateWithNewRange(const HttpByteRange& byte_range, |
119 int64_t resource_size, | 119 int64_t resource_size, |
120 bool replace_status_line); | 120 bool replace_status_line); |
121 | 121 |
122 // Creates a normalized header string. The output will be formatted exactly | |
123 // like so: | |
124 // HTTP/<version> <status_code>[ <status_text>]\n | |
125 // [<header-name>: <header-values>\n]* | |
126 // meaning, each line is \n-terminated, and there is no extra whitespace | |
127 // beyond the single space separators shown (of course, values can contain | |
128 // whitespace within them). If a given header-name appears more than once | |
129 // in the set of headers, they are combined into a single line like so: | |
130 // <header-name>: <header-value1>, <header-value2>, ...<header-valueN>\n | |
131 // | |
132 // DANGER: For some headers (e.g., "Set-Cookie"), the normalized form can be | |
133 // a lossy format. This is due to the fact that some servers generate | |
134 // Set-Cookie headers that contain unquoted commas (usually as part of the | |
135 // value of an "expires" attribute). So, use this function with caution. Do | |
136 // not expect to be able to re-parse Set-Cookie headers from this output. | |
137 // | |
138 // NOTE: Do not make any assumptions about the encoding of this output | |
139 // string. It may be non-ASCII, and the encoding used by the server is not | |
140 // necessarily known to us. Do not assume that this output is UTF-8! | |
141 // | |
142 // TODO(darin): remove this method | |
143 // | |
144 void GetNormalizedHeaders(std::string* output) const; | |
145 | |
146 // Fetch the "normalized" value of a single header, where all values for the | 122 // Fetch the "normalized" value of a single header, where all values for the |
147 // header name are separated by commas. See the GetNormalizedHeaders for | 123 // header name are separated by commas. See the GetNormalizedHeaders for |
148 // format details. Returns false if this header wasn't found. | 124 // format details. Returns false if this header wasn't found. |
149 // | 125 // |
150 // NOTE: Do not make any assumptions about the encoding of this output | 126 // NOTE: Do not make any assumptions about the encoding of this output |
151 // string. It may be non-ASCII, and the encoding used by the server is not | 127 // string. It may be non-ASCII, and the encoding used by the server is not |
152 // necessarily known to us. Do not assume that this output is UTF-8! | 128 // necessarily known to us. Do not assume that this output is UTF-8! |
153 bool GetNormalizedHeader(const std::string& name, std::string* value) const; | 129 bool GetNormalizedHeader(const std::string& name, std::string* value) const; |
154 | 130 |
155 // Returns the normalized status line. | 131 // Returns the normalized status line. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 407 |
432 // The normalized http version (consistent with what GetStatusLine() returns). | 408 // The normalized http version (consistent with what GetStatusLine() returns). |
433 HttpVersion http_version_; | 409 HttpVersion http_version_; |
434 | 410 |
435 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 411 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
436 }; | 412 }; |
437 | 413 |
438 } // namespace net | 414 } // namespace net |
439 | 415 |
440 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 416 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |