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 |
338 // Tries to extract the status line from a header block, given the first | 346 // Tries to extract the status line from a header block, given the first |
339 // line of said header block. If the status line is malformed, we'll | 347 // line of said header block. If the status line is malformed, we'll |
340 // construct a valid one. Example input: | 348 // construct a valid one. Example input: |
341 // HTTP/1.1 200 OK | 349 // HTTP/1.1 200 OK |
342 // with line_begin and end pointing at the begin and end of this line. | 350 // with line_begin and end pointing at the begin and end of this line. |
343 // Output will be a normalized version of this. | 351 // Output will be a normalized version of this. |
344 void ParseStatusLine(std::string::const_iterator line_begin, | 352 void ParseStatusLine(std::string::const_iterator line_begin, |
345 std::string::const_iterator line_end, | 353 std::string::const_iterator line_end, |
346 bool has_headers); | 354 bool has_headers); |
347 | 355 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 425 |
418 // The parsed http version number (not normalized). | 426 // The parsed http version number (not normalized). |
419 HttpVersion parsed_http_version_; | 427 HttpVersion parsed_http_version_; |
420 | 428 |
421 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); | 429 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); |
422 }; | 430 }; |
423 | 431 |
424 } // namespace net | 432 } // namespace net |
425 | 433 |
426 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ | 434 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |