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> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/basictypes.h" | |
12 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
15 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
16 #include "net/http/http_version.h" | 19 #include "net/http/http_version.h" |
17 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
18 | 21 |
19 namespace base { | 22 namespace base { |
20 class Pickle; | 23 class Pickle; |
21 class PickleIterator; | 24 class PickleIterator; |
22 class Time; | 25 class Time; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Replaces the current status line with the provided one (|new_status| should | 100 // Replaces the current status line with the provided one (|new_status| should |
98 // not have any EOL). | 101 // not have any EOL). |
99 void ReplaceStatusLine(const std::string& new_status); | 102 void ReplaceStatusLine(const std::string& new_status); |
100 | 103 |
101 // Updates headers (Content-Length and Content-Range) in the |headers| to | 104 // Updates headers (Content-Length and Content-Range) in the |headers| to |
102 // include the right content length and range for |byte_range|. This also | 105 // include the right content length and range for |byte_range|. This also |
103 // updates HTTP status line if |replace_status_line| is true. | 106 // updates HTTP status line if |replace_status_line| is true. |
104 // |byte_range| must have a valid, bounded range (i.e. coming from a valid | 107 // |byte_range| must have a valid, bounded range (i.e. coming from a valid |
105 // response or should be usable for a response). | 108 // response or should be usable for a response). |
106 void UpdateWithNewRange(const HttpByteRange& byte_range, | 109 void UpdateWithNewRange(const HttpByteRange& byte_range, |
107 int64 resource_size, | 110 int64_t resource_size, |
108 bool replace_status_line); | 111 bool replace_status_line); |
109 | 112 |
110 // Creates a normalized header string. The output will be formatted exactly | 113 // Creates a normalized header string. The output will be formatted exactly |
111 // like so: | 114 // like so: |
112 // HTTP/<version> <status_code>[ <status_text>]\n | 115 // HTTP/<version> <status_code>[ <status_text>]\n |
113 // [<header-name>: <header-values>\n]* | 116 // [<header-name>: <header-values>\n]* |
114 // meaning, each line is \n-terminated, and there is no extra whitespace | 117 // meaning, each line is \n-terminated, and there is no extra whitespace |
115 // beyond the single space separators shown (of course, values can contain | 118 // beyond the single space separators shown (of course, values can contain |
116 // whitespace within them). If a given header-name appears more than once | 119 // whitespace within them). If a given header-name appears more than once |
117 // in the set of headers, they are combined into a single line like so: | 120 // in the set of headers, they are combined into a single line like so: |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 253 |
251 // Determines if this response indicates a keep-alive connection. | 254 // Determines if this response indicates a keep-alive connection. |
252 bool IsKeepAlive() const; | 255 bool IsKeepAlive() const; |
253 | 256 |
254 // Returns true if this response has a strong etag or last-modified header. | 257 // Returns true if this response has a strong etag or last-modified header. |
255 // See section 13.3.3 of RFC 2616. | 258 // See section 13.3.3 of RFC 2616. |
256 bool HasStrongValidators() const; | 259 bool HasStrongValidators() const; |
257 | 260 |
258 // Extracts the value of the Content-Length header or returns -1 if there is | 261 // Extracts the value of the Content-Length header or returns -1 if there is |
259 // no such header in the response. | 262 // no such header in the response. |
260 int64 GetContentLength() const; | 263 int64_t GetContentLength() const; |
261 | 264 |
262 // Extracts the value of the specified header or returns -1 if there is no | 265 // Extracts the value of the specified header or returns -1 if there is no |
263 // such header in the response. | 266 // such header in the response. |
264 int64 GetInt64HeaderValue(const std::string& header) const; | 267 int64_t GetInt64HeaderValue(const std::string& header) const; |
265 | 268 |
266 // Extracts the values in a Content-Range header and returns true if they are | 269 // Extracts the values in a Content-Range header and returns true if they are |
267 // valid for a 206 response; otherwise returns false. | 270 // valid for a 206 response; otherwise returns false. |
268 // The following values will be outputted: | 271 // The following values will be outputted: |
269 // |*first_byte_position| = inclusive position of the first byte of the range | 272 // |*first_byte_position| = inclusive position of the first byte of the range |
270 // |*last_byte_position| = inclusive position of the last byte of the range | 273 // |*last_byte_position| = inclusive position of the last byte of the range |
271 // |*instance_length| = size in bytes of the object requested | 274 // |*instance_length| = size in bytes of the object requested |
272 // If any of the above values is unknown, its value will be -1. | 275 // If any of the above values is unknown, its value will be -1. |
273 bool GetContentRange(int64* first_byte_position, | 276 bool GetContentRange(int64_t* first_byte_position, |
274 int64* last_byte_position, | 277 int64_t* last_byte_position, |
275 int64* instance_length) const; | 278 int64_t* instance_length) const; |
276 | 279 |
277 // Returns true if the response is chunk-encoded. | 280 // Returns true if the response is chunk-encoded. |
278 bool IsChunkEncoded() const; | 281 bool IsChunkEncoded() const; |
279 | 282 |
280 // Creates a Value for use with the NetLog containing the response headers. | 283 // Creates a Value for use with the NetLog containing the response headers. |
281 scoped_ptr<base::Value> NetLogCallback(NetLogCaptureMode capture_mode) const; | 284 scoped_ptr<base::Value> NetLogCallback(NetLogCaptureMode capture_mode) const; |
282 | 285 |
283 // Takes in a Value created by the above function, and attempts to create a | 286 // Takes in a Value created by the above function, and attempts to create a |
284 // copy of the original headers. Returns true on success. On failure, | 287 // copy of the original headers. Returns true on success. On failure, |
285 // clears |http_response_headers|. | 288 // clears |http_response_headers|. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 401 |
399 // The normalized http version (consistent with what GetStatusLine() returns). | 402 // The normalized http version (consistent with what GetStatusLine() returns). |
400 HttpVersion http_version_; | 403 HttpVersion http_version_; |
401 | 404 |
402 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 405 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
403 }; | 406 }; |
404 | 407 |
405 } // namespace net | 408 } // namespace net |
406 | 409 |
407 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 410 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |