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

Unified Diff: net/http/http_util.cc

Issue 2559243003: Extend with a language code in http accept languages
Patch Set: Rebased, fixed nits and handed over this CL :( Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_icu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index 26552e32555c7bc9337be763de310541e0220b62..bfa7691d1d031c243889469b464b60d02ce04864 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -821,40 +821,6 @@ std::string HttpUtil::ConvertHeadersBackToHTTPResponse(const std::string& str) {
return disassembled_headers;
}
-// TODO(jungshik): 1. If the list is 'fr-CA,fr-FR,en,de', we have to add
-// 'fr' after 'fr-CA' with the same q-value as 'fr-CA' because
-// web servers, in general, do not fall back to 'fr' and may end up picking
-// 'en' which has a lower preference than 'fr-CA' and 'fr-FR'.
-// 2. This function assumes that the input is a comma separated list
-// without any whitespace. As long as it comes from the preference and
-// a user does not manually edit the preference file, it's the case. Still,
-// we may have to make it more robust.
-std::string HttpUtil::GenerateAcceptLanguageHeader(
- const std::string& raw_language_list) {
- // We use integers for qvalue and qvalue decrement that are 10 times
- // larger than actual values to avoid a problem with comparing
- // two floating point numbers.
- const unsigned int kQvalueDecrement10 = 2;
- unsigned int qvalue10 = 10;
- base::StringTokenizer t(raw_language_list, ",");
- std::string lang_list_with_q;
- while (t.GetNext()) {
- std::string language = t.token();
- if (qvalue10 == 10) {
- // q=1.0 is implicit.
- lang_list_with_q = language;
- } else {
- DCHECK_LT(qvalue10, 10U);
- base::StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(),
- qvalue10);
- }
- // It does not make sense to have 'q=0'.
- if (qvalue10 > kQvalueDecrement10)
- qvalue10 -= kQvalueDecrement10;
- }
- return lang_list_with_q;
-}
-
void HttpUtil::AppendHeaderIfMissing(const char* header_name,
const std::string& header_value,
std::string* headers) {
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_icu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698