summaryrefslogtreecommitdiffstats
path: root/net/http/http_util.h
diff options
context:
space:
mode:
authorjungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 00:39:47 +0000
committerjungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 00:39:47 +0000
commitfe3d9d77e47bfad0b6984bdd31a1e72b8fc8d2d4 (patch)
treedbed66e02abd1f8039d8fc05b48a8e18ed73f4b3 /net/http/http_util.h
parent7b7d41fc206600571a3352e83a27334ad81775f2 (diff)
downloadchromium_src-fe3d9d77e47bfad0b6984bdd31a1e72b8fc8d2d4.zip
chromium_src-fe3d9d77e47bfad0b6984bdd31a1e72b8fc8d2d4.tar.gz
chromium_src-fe3d9d77e47bfad0b6984bdd31a1e72b8fc8d2d4.tar.bz2
Add q-values to languages in Accept-Language HTTP header to be compatible with Apache.
Add q-values to charsets in Accept-Charset header in the same way as Firefox does. BUG=5899 TEST=HttpUtilTest.Accept* (net_unittest) Review URL: http://codereview.chromium.org/17340 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_util.h')
-rw-r--r--net/http/http_util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/net/http/http_util.h b/net/http/http_util.h
index d46ace4..9966c60 100644
--- a/net/http/http_util.h
+++ b/net/http/http_util.h
@@ -102,6 +102,28 @@ class HttpUtil {
// the end-of-headers marker as defined by LocateEndOfHeaders.
static std::string AssembleRawHeaders(const char* buf, int buf_len);
+ // Given a comma separated ordered list of language codes, return
+ // the list with a qvalue appended to each language.
+ // The way qvalues are assigned is rather simple. The qvalue
+ // 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 qvalue of 0.2. Also, note that the 1st language
+ // will not have a qvalue added because the absence of a qvalue 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* qvalue 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).
+ static std::string GenerateAcceptLanguageHeader(
+ const std::string& raw_language_list);
+
+ // Given a charset, return the list with a qvalue. If charset is utf-8,
+ // it will return 'utf-8,*;q=0.5'. Otherwise (e.g. 'euc-jp'), it'll return
+ // 'euc-jp,utf-8;q=0.7,*;q=0.3'.
+ static std::string GenerateAcceptCharsetHeader(const std::string& charset);
+
// Used to iterate over the name/value pairs of HTTP headers. To iterate
// over the values in a multi-value header, use ValuesIterator.
// See AssembleRawHeaders for joining line continuations (this iterator