]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1188: Check for --fail HTTP status
authorJay Satiro <raysatiro@yahoo.com>
Fri, 19 Feb 2021 23:30:18 +0000 (18:30 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Sat, 20 Feb 2021 19:41:13 +0000 (14:41 -0500)
- Change the test to check for curl error on HTTP 404 Not Found.

test1188 tests "--write-out with %{onerror} and %{urlnum} to stderr".
Prior to this change it did that by specifying a non-existent host which
would cause an error. ISPs may hijack DNS and resolve non-existent hosts
so the test would not work if that was the case.

Ref: https://en.wikipedia.org/wiki/DNS_hijacking#Manipulation_by_ISPs
Ref: https://github.com/curl/curl/issues/6621
Ref: https://github.com/curl/curl/pull/6623

Closes https://github.com/curl/curl/pull/6637

tests/data/test1188

index 8912b391a94cdbd4e880d162050b5f8b2c820c8c..6078ee4834106ba6b284315dfdeb382d7aad32a8 100644 (file)
@@ -9,12 +9,11 @@ HTTP GET
 
 # Server-side
 <reply>
-<data nocheck="yes">
-HTTP/1.1 200 OK\r
-Content-Length: 3\r
+<data>
+HTTP/1.1 404 Not Found\r
+Content-Length: 0\r
 Connection: close\r
 \r
-hi
 </data>
 </reply>
 
@@ -27,7 +26,7 @@ http
 --write-out with %{onerror} and %{urlnum} to stderr
  </name>
 <command>
-http://non-existing-host.haxx.se:%NOLISTENPORT/we/want/our/1188 http://%HOSTIP:%HTTPPORT/we/want/our/1188 -w '%{onerror}%{stderr}%{urlnum} says %{exitcode} %{errormsg}\n' -s
+-f -s -w '%{onerror}%{stderr}%{urlnum} says %{exitcode} %{errormsg}\n' http://%HOSTIP:%HTTPPORT/we/want/our/1188 http://%HOSTIP:%HTTPPORT/we/want/our/1188
 </command>
 </client>
 
@@ -39,9 +38,19 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 \r
+GET /we/want/our/1188 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
 </protocol>
 <stderr mode="text">
-0 says 6 Could not resolve host: non-existing-host.haxx.se
+0 says 22 The requested URL returned error: 404
+1 says 22 The requested URL returned error: 404
 </stderr>
+# 22 is CURLE_HTTP_RETURNED_ERROR
+<errorcode>
+22
+</errorcode>
 </verify>
 </testcase>