Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: net/http/http_util.cc

Issue 273072: Adding a Find method to the HeadersIterator class.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698