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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.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/http/http_version.h" | 17 #include "net/http/http_version.h" |
| 17 | 18 |
| 18 class Pickle; | 19 class Pickle; |
| 19 class PickleIterator; | 20 class PickleIterator; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class Time; | 23 class Time; |
| 23 class TimeDelta; | 24 class TimeDelta; |
| 25 class Value; | |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace net { | 28 namespace net { |
| 27 | 29 |
| 28 // HttpResponseHeaders: parses and holds HTTP response headers. | 30 // HttpResponseHeaders: parses and holds HTTP response headers. |
| 29 class NET_EXPORT HttpResponseHeaders | 31 class NET_EXPORT HttpResponseHeaders |
| 30 : public base::RefCountedThreadSafe<HttpResponseHeaders> { | 32 : public base::RefCountedThreadSafe<HttpResponseHeaders> { |
| 31 public: | 33 public: |
| 32 // Persist options. | 34 // Persist options. |
| 33 typedef int PersistOptions; | 35 typedef int PersistOptions; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 // |*last_byte_position| = inclusive position of the last byte of the range | 239 // |*last_byte_position| = inclusive position of the last byte of the range |
| 238 // |*instance_length| = size in bytes of the object requested | 240 // |*instance_length| = size in bytes of the object requested |
| 239 // If any of the above values is unknown, its value will be -1. | 241 // If any of the above values is unknown, its value will be -1. |
| 240 bool GetContentRange(int64* first_byte_position, | 242 bool GetContentRange(int64* first_byte_position, |
| 241 int64* last_byte_position, | 243 int64* last_byte_position, |
| 242 int64* instance_length) const; | 244 int64* instance_length) const; |
| 243 | 245 |
| 244 // Returns true if the response is chunk-encoded. | 246 // Returns true if the response is chunk-encoded. |
| 245 bool IsChunkEncoded() const; | 247 bool IsChunkEncoded() const; |
| 246 | 248 |
| 249 // Returns a Value for use with the NetLog containing the response headers. | |
|
eroman
2012/06/06 21:27:11
optional nit: Returns --> Creates (to imply caller
mmenke
2012/06/07 19:20:46
Done.
| |
| 250 base::Value* NetLogCallback(NetLog::LogLevel log_level) const; | |
| 251 | |
| 252 // Takes in a Value created by the above function, and attempts to extract the | |
| 253 // original response headers. Returns a duplicate of the original headers | |
| 254 // on success. On failure, returns NULL. | |
| 255 // TODO(mmenke): Long term, we want to remove this, and migrate external | |
| 256 // consumers to be NetworkDelegates. | |
| 257 static scoped_refptr<HttpResponseHeaders> FromNetLogParam( | |
|
eroman
2012/06/06 21:27:11
nit: for consistency with the other converters, I
mmenke
2012/06/07 19:20:46
Done.
| |
| 258 const base::Value* event_param); | |
| 259 | |
| 247 // Returns the HTTP response code. This is 0 if the response code text seems | 260 // Returns the HTTP response code. This is 0 if the response code text seems |
| 248 // to exist but could not be parsed. Otherwise, it defaults to 200 if the | 261 // to exist but could not be parsed. Otherwise, it defaults to 200 if the |
| 249 // response code is not found in the raw headers. | 262 // response code is not found in the raw headers. |
| 250 int response_code() const { return response_code_; } | 263 int response_code() const { return response_code_; } |
| 251 | 264 |
| 252 // Returns the raw header string. | 265 // Returns the raw header string. |
| 253 const std::string& raw_headers() const { return raw_headers_; } | 266 const std::string& raw_headers() const { return raw_headers_; } |
| 254 | 267 |
| 255 private: | 268 private: |
| 256 friend class base::RefCountedThreadSafe<HttpResponseHeaders>; | 269 friend class base::RefCountedThreadSafe<HttpResponseHeaders>; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 | 373 |
| 361 // The parsed http version number (not normalized). | 374 // The parsed http version number (not normalized). |
| 362 HttpVersion parsed_http_version_; | 375 HttpVersion parsed_http_version_; |
| 363 | 376 |
| 364 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 377 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
| 365 }; | 378 }; |
| 366 | 379 |
| 367 } // namespace net | 380 } // namespace net |
| 368 | 381 |
| 369 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 382 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
| OLD | NEW |