| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 635 |
| 636 values_begin_ = colon + 1; | 636 values_begin_ = colon + 1; |
| 637 TrimLWS(&values_begin_, &values_end_); | 637 TrimLWS(&values_begin_, &values_end_); |
| 638 | 638 |
| 639 // if we got a header name, then we are done. | 639 // if we got a header name, then we are done. |
| 640 return true; | 640 return true; |
| 641 } | 641 } |
| 642 return false; | 642 return false; |
| 643 } | 643 } |
| 644 | 644 |
| 645 bool HttpUtil::HeadersIterator::AdvanceTo(const char* name) { |
| 646 DCHECK(name != NULL); |
| 647 DCHECK_EQ(0, StringToLowerASCII<std::string>(name).compare(name)) |
| 648 << "the header name must be in all lower case"; |
| 649 |
| 650 while (GetNext()) { |
| 651 if (LowerCaseEqualsASCII(name_begin_, name_end_, name)) { |
| 652 return true; |
| 653 } |
| 654 } |
| 655 |
| 656 return false; |
| 657 } |
| 658 |
| 645 HttpUtil::ValuesIterator::ValuesIterator( | 659 HttpUtil::ValuesIterator::ValuesIterator( |
| 646 string::const_iterator values_begin, | 660 string::const_iterator values_begin, |
| 647 string::const_iterator values_end, | 661 string::const_iterator values_end, |
| 648 char delimiter) | 662 char delimiter) |
| 649 : values_(values_begin, values_end, string(1, delimiter)) { | 663 : values_(values_begin, values_end, string(1, delimiter)) { |
| 650 values_.set_quote_chars("\'\""); | 664 values_.set_quote_chars("\'\""); |
| 651 } | 665 } |
| 652 | 666 |
| 653 bool HttpUtil::ValuesIterator::GetNext() { | 667 bool HttpUtil::ValuesIterator::GetNext() { |
| 654 while (values_.GetNext()) { | 668 while (values_.GetNext()) { |
| 655 value_begin_ = values_.token_begin(); | 669 value_begin_ = values_.token_begin(); |
| 656 value_end_ = values_.token_end(); | 670 value_end_ = values_.token_end(); |
| 657 TrimLWS(&value_begin_, &value_end_); | 671 TrimLWS(&value_begin_, &value_end_); |
| 658 | 672 |
| 659 // bypass empty values. | 673 // bypass empty values. |
| 660 if (value_begin_ != value_end_) | 674 if (value_begin_ != value_end_) |
| 661 return true; | 675 return true; |
| 662 } | 676 } |
| 663 return false; | 677 return false; |
| 664 } | 678 } |
| 665 | 679 |
| 666 } // namespace net | 680 } // namespace net |
| OLD | NEW |