path: root/t/lib-httpd
diff options
authorJeff King <>2014-05-22 09:29:47 (GMT)
committerJunio C Hamano <>2014-05-27 16:57:00 (GMT)
commitbf197fd7eebcb3579dd659af35822ce88adc66c8 (patch)
tree746ca7087ca1a5e48a30a20262e831ce2f83c426 /t/lib-httpd
parentdbcf2bd3dec1244fdbafb3ec7312ed14d83c0025 (diff)
http: extract type/subtype portion of content-type
When we get a content-type from curl, we get the whole header line, including any parameters, and without any normalization (like downcasing or whitespace) applied. If we later try to match it with strcmp() or even strcasecmp(), we may get false negatives. This could cause two visible behaviors: 1. We might fail to recognize a smart-http server by its content-type. 2. We might fail to relay text/plain error messages to users (especially if they contain a charset parameter). This patch teaches the http code to extract and normalize just the type/subtype portion of the string. This is technically passing out less information to the callers, who can no longer see the parameters. But none of the current callers cares, and a future patch will add back an easier-to-use method for accessing those parameters. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/lib-httpd')
1 files changed, 7 insertions, 1 deletions
diff --git a/t/lib-httpd/ b/t/lib-httpd/
index 786f281..23cec97 100755
--- a/t/lib-httpd/
+++ b/t/lib-httpd/
@@ -3,6 +3,7 @@
printf "Status: 500 Intentional Breakage\n"
printf "Content-Type: "
case "$PATH_INFO" in
printf "text/html"
@@ -10,8 +11,13 @@ case "$PATH_INFO" in
printf "text/plain"
+ printf "text/plain; charset=utf-8"
+ charset=utf-8
+ ;;
printf "\n"
printf "\n"
-printf "this is the error message\n"
+printf "this is the error message\n" |
+iconv -f us-ascii -t $charset