OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 base::StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(), | 677 base::StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(), |
678 qvalue10); | 678 qvalue10); |
679 } | 679 } |
680 // It does not make sense to have 'q=0'. | 680 // It does not make sense to have 'q=0'. |
681 if (qvalue10 > kQvalueDecrement10) | 681 if (qvalue10 > kQvalueDecrement10) |
682 qvalue10 -= kQvalueDecrement10; | 682 qvalue10 -= kQvalueDecrement10; |
683 } | 683 } |
684 return lang_list_with_q; | 684 return lang_list_with_q; |
685 } | 685 } |
686 | 686 |
687 std::string HttpUtil::GenerateAcceptCharsetHeader(const std::string& charset) { | |
688 std::string charset_with_q = charset; | |
689 if (LowerCaseEqualsASCII(charset, "utf-8")) { | |
690 charset_with_q += ",*;q=0.5"; | |
691 } else { | |
692 charset_with_q += ",utf-8;q=0.7,*;q=0.3"; | |
693 } | |
694 return charset_with_q; | |
695 } | |
696 | |
697 void HttpUtil::AppendHeaderIfMissing(const char* header_name, | 687 void HttpUtil::AppendHeaderIfMissing(const char* header_name, |
698 const std::string& header_value, | 688 const std::string& header_value, |
699 std::string* headers) { | 689 std::string* headers) { |
700 if (header_value.empty()) | 690 if (header_value.empty()) |
701 return; | 691 return; |
702 if (net::HttpUtil::HasHeader(*headers, header_name)) | 692 if (net::HttpUtil::HasHeader(*headers, header_name)) |
703 return; | 693 return; |
704 *headers += std::string(header_name) + ": " + header_value + "\r\n"; | 694 *headers += std::string(header_name) + ": " + header_value + "\r\n"; |
705 } | 695 } |
706 | 696 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 value_is_quoted_ = true; | 911 value_is_quoted_ = true; |
922 // Do not store iterators into this. See declaration of unquoted_value_. | 912 // Do not store iterators into this. See declaration of unquoted_value_. |
923 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 913 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
924 } | 914 } |
925 } | 915 } |
926 | 916 |
927 return true; | 917 return true; |
928 } | 918 } |
929 | 919 |
930 } // namespace net | 920 } // namespace net |
OLD | NEW |