| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 bool HttpResponseHeaders::HasHeaderValue(const std::string& name, | 478 bool HttpResponseHeaders::HasHeaderValue(const std::string& name, |
| 479 const std::string& value) const { | 479 const std::string& value) const { |
| 480 // The value has to be an exact match. This is important since | 480 // The value has to be an exact match. This is important since |
| 481 // 'cache-control: no-cache' != 'cache-control: no-cache="foo"' | 481 // 'cache-control: no-cache' != 'cache-control: no-cache="foo"' |
| 482 void* iter = NULL; | 482 void* iter = NULL; |
| 483 std::string temp; | 483 std::string temp; |
| 484 while (EnumerateHeader(&iter, name, &temp)) { | 484 while (EnumerateHeader(&iter, name, &temp)) { |
| 485 if (value.size() == temp.size() && | 485 if (value.size() == temp.size() && |
| 486 std::equal(temp.begin(), temp.end(), value.begin(), | 486 std::equal(temp.begin(), temp.end(), value.begin(), |
| 487 CaseInsensitiveCompare<char>())) | 487 base::CaseInsensitiveCompare<char>())) |
| 488 return true; | 488 return true; |
| 489 } | 489 } |
| 490 return false; | 490 return false; |
| 491 } | 491 } |
| 492 | 492 |
| 493 bool HttpResponseHeaders::HasHeader(const std::string& name) const { | 493 bool HttpResponseHeaders::HasHeader(const std::string& name) const { |
| 494 return FindHeader(0, name) != std::string::npos; | 494 return FindHeader(0, name) != std::string::npos; |
| 495 } | 495 } |
| 496 | 496 |
| 497 HttpResponseHeaders::HttpResponseHeaders() { | 497 HttpResponseHeaders::HttpResponseHeaders() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 622 |
| 623 size_t HttpResponseHeaders::FindHeader(size_t from, | 623 size_t HttpResponseHeaders::FindHeader(size_t from, |
| 624 const std::string& search) const { | 624 const std::string& search) const { |
| 625 for (size_t i = from; i < parsed_.size(); ++i) { | 625 for (size_t i = from; i < parsed_.size(); ++i) { |
| 626 if (parsed_[i].is_continuation()) | 626 if (parsed_[i].is_continuation()) |
| 627 continue; | 627 continue; |
| 628 const std::string::const_iterator& name_begin = parsed_[i].name_begin; | 628 const std::string::const_iterator& name_begin = parsed_[i].name_begin; |
| 629 const std::string::const_iterator& name_end = parsed_[i].name_end; | 629 const std::string::const_iterator& name_end = parsed_[i].name_end; |
| 630 if (static_cast<size_t>(name_end - name_begin) == search.size() && | 630 if (static_cast<size_t>(name_end - name_begin) == search.size() && |
| 631 std::equal(name_begin, name_end, search.begin(), | 631 std::equal(name_begin, name_end, search.begin(), |
| 632 CaseInsensitiveCompare<char>())) | 632 base::CaseInsensitiveCompare<char>())) |
| 633 return i; | 633 return i; |
| 634 } | 634 } |
| 635 | 635 |
| 636 return std::string::npos; | 636 return std::string::npos; |
| 637 } | 637 } |
| 638 | 638 |
| 639 void HttpResponseHeaders::AddHeader(std::string::const_iterator name_begin, | 639 void HttpResponseHeaders::AddHeader(std::string::const_iterator name_begin, |
| 640 std::string::const_iterator name_end, | 640 std::string::const_iterator name_end, |
| 641 std::string::const_iterator values_begin, | 641 std::string::const_iterator values_begin, |
| 642 std::string::const_iterator values_end) { | 642 std::string::const_iterator values_end) { |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 // We have all the values; let's verify that they make sense for a 206 | 1196 // We have all the values; let's verify that they make sense for a 206 |
| 1197 // response. | 1197 // response. |
| 1198 if (*first_byte_position < 0 || *last_byte_position < 0 || | 1198 if (*first_byte_position < 0 || *last_byte_position < 0 || |
| 1199 *instance_length < 0 || *instance_length - 1 < *last_byte_position) | 1199 *instance_length < 0 || *instance_length - 1 < *last_byte_position) |
| 1200 return false; | 1200 return false; |
| 1201 | 1201 |
| 1202 return true; | 1202 return true; |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 } // namespace net | 1205 } // namespace net |
| OLD | NEW |