| 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 parsing content-types were borrowed from Firefox: | 5 // The rules for parsing content-types were borrowed from Firefox: |
| 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
| 7 | 7 |
| 8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // and consisting of either *TEXT or combinations | 624 // and consisting of either *TEXT or combinations |
| 625 // of token, separators, and quoted-string> | 625 // of token, separators, and quoted-string> |
| 626 // | 626 // |
| 627 | 627 |
| 628 HttpUtil::HeadersIterator::HeadersIterator(string::const_iterator headers_begin, | 628 HttpUtil::HeadersIterator::HeadersIterator(string::const_iterator headers_begin, |
| 629 string::const_iterator headers_end, | 629 string::const_iterator headers_end, |
| 630 const std::string& line_delimiter) | 630 const std::string& line_delimiter) |
| 631 : lines_(headers_begin, headers_end, line_delimiter) { | 631 : lines_(headers_begin, headers_end, line_delimiter) { |
| 632 } | 632 } |
| 633 | 633 |
| 634 HttpUtil::HeadersIterator::~HeadersIterator() { |
| 635 } |
| 636 |
| 634 bool HttpUtil::HeadersIterator::GetNext() { | 637 bool HttpUtil::HeadersIterator::GetNext() { |
| 635 while (lines_.GetNext()) { | 638 while (lines_.GetNext()) { |
| 636 name_begin_ = lines_.token_begin(); | 639 name_begin_ = lines_.token_begin(); |
| 637 values_end_ = lines_.token_end(); | 640 values_end_ = lines_.token_end(); |
| 638 | 641 |
| 639 string::const_iterator colon = find(name_begin_, values_end_, ':'); | 642 string::const_iterator colon = find(name_begin_, values_end_, ':'); |
| 640 if (colon == values_end_) | 643 if (colon == values_end_) |
| 641 continue; // skip malformed header | 644 continue; // skip malformed header |
| 642 | 645 |
| 643 name_end_ = colon; | 646 name_end_ = colon; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 679 } |
| 677 | 680 |
| 678 HttpUtil::ValuesIterator::ValuesIterator( | 681 HttpUtil::ValuesIterator::ValuesIterator( |
| 679 string::const_iterator values_begin, | 682 string::const_iterator values_begin, |
| 680 string::const_iterator values_end, | 683 string::const_iterator values_end, |
| 681 char delimiter) | 684 char delimiter) |
| 682 : values_(values_begin, values_end, string(1, delimiter)) { | 685 : values_(values_begin, values_end, string(1, delimiter)) { |
| 683 values_.set_quote_chars("\'\""); | 686 values_.set_quote_chars("\'\""); |
| 684 } | 687 } |
| 685 | 688 |
| 689 HttpUtil::ValuesIterator::~ValuesIterator() { |
| 690 } |
| 691 |
| 686 bool HttpUtil::ValuesIterator::GetNext() { | 692 bool HttpUtil::ValuesIterator::GetNext() { |
| 687 while (values_.GetNext()) { | 693 while (values_.GetNext()) { |
| 688 value_begin_ = values_.token_begin(); | 694 value_begin_ = values_.token_begin(); |
| 689 value_end_ = values_.token_end(); | 695 value_end_ = values_.token_end(); |
| 690 TrimLWS(&value_begin_, &value_end_); | 696 TrimLWS(&value_begin_, &value_end_); |
| 691 | 697 |
| 692 // bypass empty values. | 698 // bypass empty values. |
| 693 if (value_begin_ != value_end_) | 699 if (value_begin_ != value_end_) |
| 694 return true; | 700 return true; |
| 695 } | 701 } |
| 696 return false; | 702 return false; |
| 697 } | 703 } |
| 698 | 704 |
| 699 } // namespace net | 705 } // namespace net |
| OLD | NEW |