]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: check for "Host:" case insensitively
authorDaniel Stenberg <daniel@haxx.se>
Thu, 25 Jan 2024 08:05:19 +0000 (09:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Jan 2024 12:53:09 +0000 (13:53 +0100)
When checking if the user wants to replace the header, the check should
be case insensitive.

Adding test 461 to verify

Found-by: Dan Fandrich
Ref: #12782
Closes #12784

lib/http.c
tests/data/Makefile.inc
tests/data/test461 [new file with mode: 0644]

index 90f489d7ab8dba148c88be13eaedf8a79df8963d..6c7ee56b24c2e17b81b60de8a74554d67577e861 100644 (file)
@@ -2192,7 +2192,7 @@ CURLcode Curl_http_host(struct Curl_easy *data, struct connectdata *conn)
     }
 #endif
 
-    if(strcmp("Host:", ptr)) {
+    if(!strcasecompare("Host:", ptr)) {
       aptr->host = aprintf("Host:%s\r\n", &ptr[5]);
       if(!aptr->host)
         return CURLE_OUT_OF_MEMORY;
index 64859632a119b4a9d054cb2b3a3f0420b951534c..d7fa782847a56a3ed20851c77b7094f974de5fb7 100644 (file)
@@ -72,7 +72,7 @@ test417 test418 test419 test420 test421 test422 test423 test424 test425 \
 test426 test427 test428 test429 test430 test431 test432 test433 test434 \
 test435 test436 test437 test438 test439 test440 test441 test442 test443 \
 test444 test445 test446 test447 test448 test449 test450 test451 test452 \
-test453 test454 test455 test456 test457 test458 test459 test460 \
+test453 test454 test455 test456 test457 test458 test459 test460 test461 \
 \
 test490 test491 test492 test493 test494 test495 test496 test497 test498 \
 \
diff --git a/tests/data/test461 b/tests/data/test461
new file mode 100644 (file)
index 0000000..03d7c7a
--- /dev/null
@@ -0,0 +1,48 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+--header
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data crlf="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+disable Host: when specified as lower case
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER -H host:
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="yes">
+GET /%TESTNUMBER HTTP/1.1
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>