From: "Yi, EungJun" <semtlenori@gmail.com>
To: Peter Krefting <peter@softwolves.pp.se>
Cc: git@vger.kernel.org, Yi EungJun <eungjun.yi@navercorp.com>
Subject: Re: [PATCH] http: Add Accept-Language header if possible
Date: Fri, 11 Jul 2014 18:05:56 +0900 [thread overview]
Message-ID: <CAFT+Tg8Z5z=vTcCTbwKMQeTAaqpTYzr5OzdfedV0q8J5KzG-Yg@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1407091127490.22132@ds9.cixit.se>
2014-07-09 19:40 GMT+09:00 Peter Krefting <peter@softwolves.pp.se>:
> Yi EungJun:
>
>
>> Example:
>> LANGUAGE= -> ""
>> LANGUAGE=ko -> "Accept-Language: ko; q=1.000, *; q=0.001"
>> LANGUAGE=ko:en -> "Accept-Language: ko; q=1.000, en; q=0.999, *; q=0.001"
>
>
> Avoid adding "q=1.000". It is redundant (the default for any unqualified
> language names is 1.0, and additionally there has historically been some
> buggy servers that failed if it was included.
Ok, I'll fix it.
>
>
>> + p1 = getenv("LANGUAGE");
>
>
> You need a fallback mechanism here to parse all the possible language
> variables. I would use the first one I find of these:
>
> 1. LANGUAGE
> 2. LC_ALL
> 3. LC_MESSAGES
> 4. LANG
>
> Only "LANGUAGE" holds a colon-separated list, but the same code can parse
> all of them, just yielding a single entry for the others.
I'll use setlocale(LC_MESSAGES, NULL) as well as getenv("LANGUAGE").
>
>
>> + strbuf_add(buf, p1, p2 - p1);
>
>
> The tokens are on the form language_COUNTRY.encoding@identifier, whereas
> Accept-Language wants language-COUNTRY, so you need to a) replace "_" with
> "-", and b) chop off anything following a "." or "@".
>
>
>> + strbuf_addf(buf, "; q=%.3f", q);
>> + q -= 0.001;
>
>
> Three decimals seems a bit overkill, but some experimentation might be
> necessary.
I'll use three decimals only if there are 100 or more preferred languages.
>
>
>> + strbuf_addstr(buf, "*; q=0.001\r\n");
>
>
> You should probably also add an explicit "en" here, if none was already
> included. I've seen some servers break horribly if "en" isn't included.
I'll send Accept-Language only if there is at least one preferred
language. Is it enough?
Thanks for your review.
next prev parent reply other threads:[~2014-07-11 9:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-08 15:54 [PATCH] http: Add Accept-Language header if possible Yi EungJun
2014-07-08 21:52 ` Eric Sunshine
[not found] ` <CAFT+Tg-6fR9OJ93TT7ww3x=zYHY=Dh5u-7owgQMBK5o_JKLEaA@mail.gmail.com>
[not found] ` <CAPig+cQ05pzU9uVBqS8tBHvB8_3qAtgsPYz1sGhpa0W1CVymqA@mail.gmail.com>
2014-07-11 16:35 ` Yi, EungJun
2014-07-09 5:10 ` Jeff King
2014-07-09 5:46 ` Yi, EungJun
2014-07-09 6:18 ` Jeff King
2014-07-09 10:46 ` Peter Krefting
2014-07-10 20:10 ` Jeff King
2014-07-11 9:43 ` Yi, EungJun
2014-07-12 10:11 ` Peter Krefting
2014-07-09 10:40 ` Peter Krefting
2014-07-11 9:05 ` Yi, EungJun [this message]
2015-01-22 7:54 [PATCH v7 1/1] " Junio C Hamano
2015-01-27 15:51 ` [PATCH v8 0/1] " Yi EungJun
2015-01-27 15:51 ` [PATCH] " Yi EungJun
2015-01-27 23:34 ` Junio C Hamano
2015-01-28 6:15 ` Junio C Hamano
2015-01-28 11:59 ` Yi, EungJun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFT+Tg8Z5z=vTcCTbwKMQeTAaqpTYzr5OzdfedV0q8J5KzG-Yg@mail.gmail.com' \
--to=semtlenori@gmail.com \
--cc=eungjun.yi@navercorp.com \
--cc=git@vger.kernel.org \
--cc=peter@softwolves.pp.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.