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

Unified Diff: net/http/http_util_icu.h

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.cc ('k') | net/http/http_util_icu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util_icu.h
diff --git a/net/http/http_util_icu.h b/net/http/http_util_icu.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b32ae9d5d01af36043e1df72ec8c1aeccbd82a3
--- /dev/null
+++ b/net/http/http_util_icu.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_HTTP_HTTP_UTIL_ICU_H_
+#define NET_HTTP_HTTP_UTIL_ICU_H_
+
+#include <string>
+
+#include "net/base/net_export.h"
+
+namespace net {
+
+namespace http_util_icu {
+// Given a comma separated ordered list of language codes, return the list
+// with a q-value appended to each language. The way q-values are assigned is
+// rather simple. The q-value starts with 1.0 and is decremented by 0.2 for
+// each successive entry in the list until it reaches 0.2. All the entries
+// after that are assigned the same q-value of 0.2. Also, note that 1st
+// language will not have a q-value added because the absence of a q-value
+// implicitly means q=1.0.
+//
+// When making a http request, this should be used to determine what to put in
+// Accept-Language header. If a comma separated list of language codes
+// *without* q-value is sent, web servers regard all of them as having q=1.0
+// and pick one of them even though it may not be at the beginning of the list
+// (see http://crbug.com/5899).
+NET_EXPORT std::string GenerateAcceptLanguageHeader(
+ const std::string& raw_language_list);
+
+} // namespace http_util_icu
+
+} // namespace net
+
+#endif // NET_HTTP_HTTP_UTIL_ICU_H_
« no previous file with comments | « net/http/http_util.cc ('k') | net/http/http_util_icu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698