| 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 // The rules for header parsing were borrowed from Firefox: | 5 // The rules for header parsing were borrowed from Firefox: |
| 6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo
nseHead.cpp | 6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo
nseHead.cpp |
| 7 // The rules for parsing content-types were also borrowed from Firefox: | 7 // The rules for parsing content-types were also borrowed from Firefox: |
| 8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
| 9 | 9 |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 648 |
| 649 std::string::const_iterator dot = std::find(p, line_end, '.'); | 649 std::string::const_iterator dot = std::find(p, line_end, '.'); |
| 650 if (dot == line_end) { | 650 if (dot == line_end) { |
| 651 DVLOG(1) << "malformed version"; | 651 DVLOG(1) << "malformed version"; |
| 652 return HttpVersion(); | 652 return HttpVersion(); |
| 653 } | 653 } |
| 654 | 654 |
| 655 ++p; // from / to first digit. | 655 ++p; // from / to first digit. |
| 656 ++dot; // from . to second digit. | 656 ++dot; // from . to second digit. |
| 657 | 657 |
| 658 if (!(*p >= '0' && *p <= '9' && *dot >= '0' && *dot <= '9')) { | 658 if (!(base::IsAsciiDigit(*p) && base::IsAsciiDigit(*dot))) { |
| 659 DVLOG(1) << "malformed version number"; | 659 DVLOG(1) << "malformed version number"; |
| 660 return HttpVersion(); | 660 return HttpVersion(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 uint16_t major = *p - '0'; | 663 uint16_t major = *p - '0'; |
| 664 uint16_t minor = *dot - '0'; | 664 uint16_t minor = *dot - '0'; |
| 665 | 665 |
| 666 return HttpVersion(major, minor); | 666 return HttpVersion(major, minor); |
| 667 } | 667 } |
| 668 | 668 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 raw_headers_.append(" 200 OK"); | 703 raw_headers_.append(" 200 OK"); |
| 704 response_code_ = 200; | 704 response_code_ = 200; |
| 705 return; | 705 return; |
| 706 } | 706 } |
| 707 | 707 |
| 708 // Skip whitespace. | 708 // Skip whitespace. |
| 709 while (p < line_end && *p == ' ') | 709 while (p < line_end && *p == ' ') |
| 710 ++p; | 710 ++p; |
| 711 | 711 |
| 712 std::string::const_iterator code = p; | 712 std::string::const_iterator code = p; |
| 713 while (p < line_end && *p >= '0' && *p <= '9') | 713 while (p < line_end && base::IsAsciiDigit(*p)) |
| 714 ++p; | 714 ++p; |
| 715 | 715 |
| 716 if (p == code) { | 716 if (p == code) { |
| 717 DVLOG(1) << "missing response status number; assuming 200"; | 717 DVLOG(1) << "missing response status number; assuming 200"; |
| 718 raw_headers_.append(" 200"); | 718 raw_headers_.append(" 200"); |
| 719 response_code_ = 200; | 719 response_code_ = 200; |
| 720 return; | 720 return; |
| 721 } | 721 } |
| 722 raw_headers_.push_back(' '); | 722 raw_headers_.push_back(' '); |
| 723 raw_headers_.append(code, p); | 723 raw_headers_.append(code, p); |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 return true; | 1464 return true; |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 bool HttpResponseHeaders::IsChunkEncoded() const { | 1467 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1468 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1468 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1469 return GetHttpVersion() >= HttpVersion(1, 1) && | 1469 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1470 HasHeaderValue("Transfer-Encoding", "chunked"); | 1470 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 } // namespace net | 1473 } // namespace net |
| OLD | NEW |