| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 if ((options & PERSIST_SANS_COOKIES) == PERSIST_SANS_COOKIES) | 115 if ((options & PERSIST_SANS_COOKIES) == PERSIST_SANS_COOKIES) |
| 116 AddCookieHeaders(&filter_headers); | 116 AddCookieHeaders(&filter_headers); |
| 117 | 117 |
| 118 if ((options & PERSIST_SANS_CHALLENGES) == PERSIST_SANS_CHALLENGES) | 118 if ((options & PERSIST_SANS_CHALLENGES) == PERSIST_SANS_CHALLENGES) |
| 119 AddChallengeHeaders(&filter_headers); | 119 AddChallengeHeaders(&filter_headers); |
| 120 | 120 |
| 121 if ((options & PERSIST_SANS_HOP_BY_HOP) == PERSIST_SANS_HOP_BY_HOP) | 121 if ((options & PERSIST_SANS_HOP_BY_HOP) == PERSIST_SANS_HOP_BY_HOP) |
| 122 AddHopByHopHeaders(&filter_headers); | 122 AddHopByHopHeaders(&filter_headers); |
| 123 | 123 |
| 124 if ((options & PERSIST_SANS_RANGES) == PERSIST_SANS_RANGES) |
| 125 AddHopContentRangeHeaders(&filter_headers); |
| 126 |
| 124 std::string blob; | 127 std::string blob; |
| 125 blob.reserve(raw_headers_.size()); | 128 blob.reserve(raw_headers_.size()); |
| 126 | 129 |
| 127 // This copies the status line w/ terminator null. | 130 // This copies the status line w/ terminator null. |
| 128 // Note raw_headers_ has embedded nulls instead of \n, | 131 // Note raw_headers_ has embedded nulls instead of \n, |
| 129 // so this just copies the first header line. | 132 // so this just copies the first header line. |
| 130 blob.assign(raw_headers_.c_str(), strlen(raw_headers_.c_str()) + 1); | 133 blob.assign(raw_headers_.c_str(), strlen(raw_headers_.c_str()) + 1); |
| 131 | 134 |
| 132 for (size_t i = 0; i < parsed_.size(); ++i) { | 135 for (size_t i = 0; i < parsed_.size(); ++i) { |
| 133 DCHECK(!parsed_[i].is_continuation()); | 136 DCHECK(!parsed_[i].is_continuation()); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 void HttpResponseHeaders::AddCookieHeaders(HeaderSet* result) { | 641 void HttpResponseHeaders::AddCookieHeaders(HeaderSet* result) { |
| 639 for (size_t i = 0; i < arraysize(kCookieResponseHeaders); ++i) | 642 for (size_t i = 0; i < arraysize(kCookieResponseHeaders); ++i) |
| 640 result->insert(std::string(kCookieResponseHeaders[i])); | 643 result->insert(std::string(kCookieResponseHeaders[i])); |
| 641 } | 644 } |
| 642 | 645 |
| 643 void HttpResponseHeaders::AddChallengeHeaders(HeaderSet* result) { | 646 void HttpResponseHeaders::AddChallengeHeaders(HeaderSet* result) { |
| 644 for (size_t i = 0; i < arraysize(kChallengeResponseHeaders); ++i) | 647 for (size_t i = 0; i < arraysize(kChallengeResponseHeaders); ++i) |
| 645 result->insert(std::string(kChallengeResponseHeaders[i])); | 648 result->insert(std::string(kChallengeResponseHeaders[i])); |
| 646 } | 649 } |
| 647 | 650 |
| 651 void HttpResponseHeaders::AddHopContentRangeHeaders(HeaderSet* result) { |
| 652 result->insert("content-range"); |
| 653 } |
| 654 |
| 648 void HttpResponseHeaders::GetMimeTypeAndCharset(std::string* mime_type, | 655 void HttpResponseHeaders::GetMimeTypeAndCharset(std::string* mime_type, |
| 649 std::string* charset) const { | 656 std::string* charset) const { |
| 650 mime_type->clear(); | 657 mime_type->clear(); |
| 651 charset->clear(); | 658 charset->clear(); |
| 652 | 659 |
| 653 std::string name = "content-type"; | 660 std::string name = "content-type"; |
| 654 std::string value; | 661 std::string value; |
| 655 | 662 |
| 656 bool had_charset = false; | 663 bool had_charset = false; |
| 657 | 664 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 } else if (*instance_length < 0 || | 1075 } else if (*instance_length < 0 || |
| 1069 *instance_length < | 1076 *instance_length < |
| 1070 *last_byte_position - *first_byte_position + 1) { | 1077 *last_byte_position - *first_byte_position + 1) { |
| 1071 return false; | 1078 return false; |
| 1072 } | 1079 } |
| 1073 | 1080 |
| 1074 return true; | 1081 return true; |
| 1075 } | 1082 } |
| 1076 | 1083 |
| 1077 } // namespace net | 1084 } // namespace net |
| OLD | NEW |