| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 class HttpByteRange; | 33 class HttpByteRange; |
| 34 | 34 |
| 35 // HttpResponseHeaders: parses and holds HTTP response headers. | 35 // HttpResponseHeaders: parses and holds HTTP response headers. |
| 36 class NET_EXPORT HttpResponseHeaders | 36 class NET_EXPORT HttpResponseHeaders |
| 37 : public base::RefCountedThreadSafe<HttpResponseHeaders> { | 37 : public base::RefCountedThreadSafe<HttpResponseHeaders> { |
| 38 public: | 38 public: |
| 39 // Persist options. | 39 // Persist options. |
| 40 typedef int PersistOptions; | 40 typedef int PersistOptions; |
| 41 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. | 41 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. |
| 42 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. | 42 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. |
| 43 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; | 43 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; |
| 44 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; | 44 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; |
| 45 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; | 45 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; |
| 46 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; | 46 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; |
| 47 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; | 47 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; |
| 48 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; | 48 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; |
| 49 | 49 |
| 50 static const char kContentRange[]; | 50 static const char kContentRange[]; |
| 51 | 51 |
| 52 // Parses the given raw_headers. raw_headers should be formatted thus: | 52 // Parses the given raw_headers. raw_headers should be formatted thus: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // TODO(darin): remove this method | 133 // TODO(darin): remove this method |
| 134 // | 134 // |
| 135 bool GetNormalizedHeader(const std::string& name, std::string* value) const; | 135 bool GetNormalizedHeader(const std::string& name, std::string* value) const; |
| 136 | 136 |
| 137 // Returns the normalized status line. For HTTP/0.9 responses (i.e., | 137 // Returns the normalized status line. For HTTP/0.9 responses (i.e., |
| 138 // responses that lack a status line), this is the manufactured string | 138 // responses that lack a status line), this is the manufactured string |
| 139 // "HTTP/0.9 200 OK". | 139 // "HTTP/0.9 200 OK". |
| 140 std::string GetStatusLine() const; | 140 std::string GetStatusLine() const; |
| 141 | 141 |
| 142 // Get the HTTP version of the normalized status line. | 142 // Get the HTTP version of the normalized status line. |
| 143 HttpVersion GetHttpVersion() const { | 143 HttpVersion GetHttpVersion() const { return http_version_; } |
| 144 return http_version_; | |
| 145 } | |
| 146 | 144 |
| 147 // Get the HTTP version determined while parsing; or (0,0) if parsing failed | 145 // Get the HTTP version determined while parsing; or (0,0) if parsing failed |
| 148 HttpVersion GetParsedHttpVersion() const { | 146 HttpVersion GetParsedHttpVersion() const { return parsed_http_version_; } |
| 149 return parsed_http_version_; | |
| 150 } | |
| 151 | 147 |
| 152 // Get the HTTP status text of the normalized status line. | 148 // Get the HTTP status text of the normalized status line. |
| 153 std::string GetStatusText() const; | 149 std::string GetStatusText() const; |
| 154 | 150 |
| 155 // Enumerate the "lines" of the response headers. This skips over the status | 151 // Enumerate the "lines" of the response headers. This skips over the status |
| 156 // line. Use GetStatusLine if you are interested in that. Note that this | 152 // line. Use GetStatusLine if you are interested in that. Note that this |
| 157 // method returns the un-coalesced response header lines, so if a response | 153 // method returns the un-coalesced response header lines, so if a response |
| 158 // header appears on multiple lines, then it will appear multiple times in | 154 // header appears on multiple lines, then it will appear multiple times in |
| 159 // this enumeration (in the order the header lines were received from the | 155 // this enumeration (in the order the header lines were received from the |
| 160 // server). Also, a given header might have an empty value. Initialize a | 156 // server). Also, a given header might have an empty value. Initialize a |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // |*last_byte_position| = inclusive position of the last byte of the range | 256 // |*last_byte_position| = inclusive position of the last byte of the range |
| 261 // |*instance_length| = size in bytes of the object requested | 257 // |*instance_length| = size in bytes of the object requested |
| 262 // If any of the above values is unknown, its value will be -1. | 258 // If any of the above values is unknown, its value will be -1. |
| 263 bool GetContentRange(int64* first_byte_position, | 259 bool GetContentRange(int64* first_byte_position, |
| 264 int64* last_byte_position, | 260 int64* last_byte_position, |
| 265 int64* instance_length) const; | 261 int64* instance_length) const; |
| 266 | 262 |
| 267 // Returns true if the response is chunk-encoded. | 263 // Returns true if the response is chunk-encoded. |
| 268 bool IsChunkEncoded() const; | 264 bool IsChunkEncoded() const; |
| 269 | 265 |
| 270 #if defined (SPDY_PROXY_AUTH_ORIGIN) | 266 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 271 // Contains instructions contained in the Chrome-Proxy header. | 267 // Contains instructions contained in the Chrome-Proxy header. |
| 272 struct DataReductionProxyInfo { | 268 struct DataReductionProxyInfo { |
| 273 DataReductionProxyInfo() : bypass_all(false) {} | 269 DataReductionProxyInfo() : bypass_all(false) {} |
| 274 | 270 |
| 275 // True if Chrome should bypass all available data reduction proxies. False | 271 // True if Chrome should bypass all available data reduction proxies. False |
| 276 // if only the currently connected data reduction proxy should be bypassed. | 272 // if only the currently connected data reduction proxy should be bypassed. |
| 277 bool bypass_all; | 273 bool bypass_all; |
| 278 | 274 |
| 279 // Amount of time to bypass the data reduction proxy or proxies. | 275 // Amount of time to bypass the data reduction proxy or proxies. |
| 280 base::TimeDelta bypass_duration; | 276 base::TimeDelta bypass_duration; |
| 281 }; | 277 }; |
| 282 | 278 |
| 283 // Returns true if the Chrome-Proxy header is present and contains a bypass | 279 // Returns true if the Chrome-Proxy header is present and contains a bypass |
| 284 // delay. Sets |proxy_info->bypass_duration| to the specified delay if greater | 280 // delay. Sets |proxy_info->bypass_duration| to the specified delay if greater |
| 285 // than 0, and to 0 otherwise to indicate that the default proxy delay | 281 // than 0, and to 0 otherwise to indicate that the default proxy delay |
| 286 // (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used. | 282 // (as specified in |ProxyList::UpdateRetryInfoOnFallback|) should be used. |
| 287 // If all available data reduction proxies should by bypassed, |bypass_all| is | 283 // If all available data reduction proxies should by bypassed, |bypass_all| is |
| 288 // set to true. |proxy_info| must be non-NULL. | 284 // set to true. |proxy_info| must be non-NULL. |
| 289 bool GetDataReductionProxyInfo(DataReductionProxyInfo* proxy_info) const; | 285 bool GetDataReductionProxyInfo(DataReductionProxyInfo* proxy_info) const; |
| 290 | 286 |
| 291 // Returns the reason why the Chrome proxy should be bypassed or not, and | 287 // Returns the reason why the Chrome proxy should be bypassed or not, and |
| 292 // populates |proxy_info| with information on how long to bypass if | 288 // populates |proxy_info| with information on how long to bypass if |
| 293 // applicable. | 289 // applicable. |
| 294 ProxyService::DataReductionProxyBypassEventType | 290 ProxyService::DataReductionProxyBypassEventType |
| 295 GetDataReductionProxyBypassEventType( | 291 GetDataReductionProxyBypassEventType( |
| 296 DataReductionProxyInfo* proxy_info) const; | 292 DataReductionProxyInfo* proxy_info) const; |
| 297 | 293 |
| 298 // Returns true if response headers contain the data reduction proxy Via | 294 // Returns true if response headers contain the data reduction proxy Via |
| 299 // header value. | 295 // header value. |
| 300 bool IsDataReductionProxyResponse() const; | 296 bool IsDataReductionProxyResponse() const; |
| 301 #endif | 297 #endif |
| 302 | 298 |
| 303 // Creates a Value for use with the NetLog containing the response headers. | 299 // Creates a Value for use with the NetLog containing the response headers. |
| 304 base::Value* NetLogCallback(NetLog::LogLevel log_level) const; | 300 base::Value* NetLogCallback(NetLog::LogLevel log_level) const; |
| 305 | 301 |
| 306 // Takes in a Value created by the above function, and attempts to create a | 302 // Takes in a Value created by the above function, and attempts to create a |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 421 |
| 426 // The parsed http version number (not normalized). | 422 // The parsed http version number (not normalized). |
| 427 HttpVersion parsed_http_version_; | 423 HttpVersion parsed_http_version_; |
| 428 | 424 |
| 429 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 425 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
| 430 }; | 426 }; |
| 431 | 427 |
| 432 } // namespace net | 428 } // namespace net |
| 433 | 429 |
| 434 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 430 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
| OLD | NEW |