| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // The members of this structure point into raw_headers_. | 328 // The members of this structure point into raw_headers_. |
| 329 struct ParsedHeader; | 329 struct ParsedHeader; |
| 330 typedef std::vector<ParsedHeader> HeaderList; | 330 typedef std::vector<ParsedHeader> HeaderList; |
| 331 | 331 |
| 332 HttpResponseHeaders(); | 332 HttpResponseHeaders(); |
| 333 ~HttpResponseHeaders(); | 333 ~HttpResponseHeaders(); |
| 334 | 334 |
| 335 // Initializes from the given raw headers. | 335 // Initializes from the given raw headers. |
| 336 void Parse(const std::string& raw_input); | 336 void Parse(const std::string& raw_input); |
| 337 | 337 |
| 338 // Helper function for ParseStatusLine. | |
| 339 // Tries to extract the "HTTP/X.Y" from a status line formatted like: | |
| 340 // HTTP/1.1 200 OK | |
| 341 // with line_begin and end pointing at the begin and end of this line. If the | |
| 342 // status line is malformed, returns HttpVersion(0,0). | |
| 343 static HttpVersion ParseVersion(std::string::const_iterator line_begin, | |
| 344 std::string::const_iterator line_end); | |
| 345 | |
| 346 // Tries to extract the status line from a header block, given the first | 338 // Tries to extract the status line from a header block, given the first |
| 347 // line of said header block. If the status line is malformed, we'll | 339 // line of said header block. If the status line is malformed, we'll |
| 348 // construct a valid one. Example input: | 340 // construct a valid one. Example input: |
| 349 // HTTP/1.1 200 OK | 341 // HTTP/1.1 200 OK |
| 350 // with line_begin and end pointing at the begin and end of this line. | 342 // with line_begin and end pointing at the begin and end of this line. |
| 351 // Output will be a normalized version of this. | 343 // Output will be a normalized version of this. |
| 352 void ParseStatusLine(std::string::const_iterator line_begin, | 344 void ParseStatusLine(std::string::const_iterator line_begin, |
| 353 std::string::const_iterator line_end, | 345 std::string::const_iterator line_end, |
| 354 bool has_headers); | 346 bool has_headers); |
| 355 | 347 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 417 |
| 426 // The parsed http version number (not normalized). | 418 // The parsed http version number (not normalized). |
| 427 HttpVersion parsed_http_version_; | 419 HttpVersion parsed_http_version_; |
| 428 | 420 |
| 429 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 421 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
| 430 }; | 422 }; |
| 431 | 423 |
| 432 } // namespace net | 424 } // namespace net |
| 433 | 425 |
| 434 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 426 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
| OLD | NEW |