summaryrefslogtreecommitdiff
path: root/t/t5550-http-fetch-dumb.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-02-18 19:44:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-02-18 19:44:57 (GMT)
commitf18e3896f7e3fd8de060aa37d9e35387a3b9282b (patch)
tree9a7797f36469d12f26738e121c7bcfb0c215d52f /t/t5550-http-fetch-dumb.sh
parentc2d081ceb9b7d710113ba162f749dbc99bc42ed2 (diff)
parentf18604bbf2c391c689a41fca14cbaeff5e106255 (diff)
downloadgit-f18e3896f7e3fd8de060aa37d9e35387a3b9282b.zip
git-f18e3896f7e3fd8de060aa37d9e35387a3b9282b.tar.gz
git-f18e3896f7e3fd8de060aa37d9e35387a3b9282b.tar.bz2
Merge branch 'ye/http-accept-language'
Using environment variable LANGUAGE and friends on the client side, HTTP-based transports now send Accept-Language when making requests. * ye/http-accept-language: http: add Accept-Language header if possible
Diffstat (limited to 't/t5550-http-fetch-dumb.sh')
-rwxr-xr-xt/t5550-http-fetch-dumb.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 6da9422..2731ad4 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -214,5 +214,47 @@ test_expect_success 'reencoding is robust to whitespace oddities' '
grep "this is the error message" stderr
'
+check_language () {
+ case "$2" in
+ '')
+ >expect
+ ;;
+ ?*)
+ echo "Accept-Language: $1" >expect
+ ;;
+ esac &&
+ GIT_CURL_VERBOSE=1 \
+ LANGUAGE=$2 \
+ git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 &&
+ tr -d '\015' <output |
+ sort -u |
+ sed -ne '/^Accept-Language:/ p' >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success 'git client sends Accept-Language based on LANGUAGE' '
+ check_language "ko-KR, *;q=0.9" ko_KR.UTF-8'
+
+test_expect_success 'git client sends Accept-Language correctly with unordinary LANGUAGE' '
+ check_language "ko-KR, *;q=0.9" "ko_KR:" &&
+ check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR::en_US" &&
+ check_language "ko-KR, *;q=0.9" ":::ko_KR" &&
+ check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR!!:en_US" &&
+ check_language "ko-KR, ja-JP;q=0.9, *;q=0.8" "ko_KR en_US:ja_JP"'
+
+test_expect_success 'git client sends Accept-Language with many preferred languages' '
+ check_language "ko-KR, en-US;q=0.9, fr-CA;q=0.8, de;q=0.7, sr;q=0.6, \
+ja;q=0.5, zh;q=0.4, sv;q=0.3, pt;q=0.2, *;q=0.1" \
+ ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt &&
+ check_language "ko-KR, en-US;q=0.99, fr-CA;q=0.98, de;q=0.97, sr;q=0.96, \
+ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \
+ ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt:nb
+'
+
+test_expect_success 'git client does not send an empty Accept-Language' '
+ GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr &&
+ ! grep "^Accept-Language:" stderr
+'
+
stop_httpd
test_done