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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 unsigned int qvalue10 = 10; | 583 unsigned int qvalue10 = 10; |
584 StringTokenizer t(raw_language_list, ","); | 584 StringTokenizer t(raw_language_list, ","); |
585 std::string lang_list_with_q; | 585 std::string lang_list_with_q; |
586 while (t.GetNext()) { | 586 while (t.GetNext()) { |
587 std::string language = t.token(); | 587 std::string language = t.token(); |
588 if (qvalue10 == 10) { | 588 if (qvalue10 == 10) { |
589 // q=1.0 is implicit. | 589 // q=1.0 is implicit. |
590 lang_list_with_q = language; | 590 lang_list_with_q = language; |
591 } else { | 591 } else { |
592 DCHECK_LT(qvalue10, 10U); | 592 DCHECK_LT(qvalue10, 10U); |
593 StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(), | 593 base::StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(), |
594 qvalue10); | 594 qvalue10); |
595 } | 595 } |
596 // It does not make sense to have 'q=0'. | 596 // It does not make sense to have 'q=0'. |
597 if (qvalue10 > kQvalueDecrement10) | 597 if (qvalue10 > kQvalueDecrement10) |
598 qvalue10 -= kQvalueDecrement10; | 598 qvalue10 -= kQvalueDecrement10; |
599 } | 599 } |
600 return lang_list_with_q; | 600 return lang_list_with_q; |
601 } | 601 } |
602 | 602 |
603 std::string HttpUtil::GenerateAcceptCharsetHeader(const std::string& charset) { | 603 std::string HttpUtil::GenerateAcceptCharsetHeader(const std::string& charset) { |
604 std::string charset_with_q = charset; | 604 std::string charset_with_q = charset; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 value_is_quoted_ = true; | 861 value_is_quoted_ = true; |
862 // Do not store iterators into this. See declaration of unquoted_value_. | 862 // Do not store iterators into this. See declaration of unquoted_value_. |
863 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 863 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 return true; | 867 return true; |
868 } | 868 } |
869 | 869 |
870 } // namespace net | 870 } // namespace net |
OLD | NEW |