diff --git a/ext/curl/tests/curl_curlfile_seek.phpt b/ext/curl/tests/curl_curlfile_seek.phpt new file mode 100644 index 000000000000..8ebaab92bc43 --- /dev/null +++ b/ext/curl/tests/curl_curlfile_seek.phpt @@ -0,0 +1,22 @@ +--TEST-- +curl seek within uploaded file +--EXTENSIONS-- +curl +--FILE-- + new CURLFile(__DIR__ . '/curl_testdata1.txt') +]); +curl_exec($ch); + +?> +--EXPECT-- +curl_testdata1.txt|application/octet-stream|6 diff --git a/ext/curl/tests/curl_errors.phpt b/ext/curl/tests/curl_errors.phpt new file mode 100644 index 000000000000..cf3d8c60770a --- /dev/null +++ b/ext/curl/tests/curl_errors.phpt @@ -0,0 +1,110 @@ +--TEST-- +curl error constants +--EXTENSIONS-- +curl +--FILE-- + +--FILE-- + +--EXPECT-- +pong +bool(false) +bool(true) diff --git a/ext/curl/tests/curl_getinfo_CURLINFO_HEADER_OUT.phpt b/ext/curl/tests/curl_getinfo_CURLINFO_HEADER_OUT.phpt new file mode 100644 index 000000000000..c03bd3bc6033 --- /dev/null +++ b/ext/curl/tests/curl_getinfo_CURLINFO_HEADER_OUT.phpt @@ -0,0 +1,42 @@ +--TEST-- +curl_getinfo CURLINFO_HEADER_OUT +--DESCRIPTION-- +Verify that CURLINFO_HEADER_OUT returns the request header sent on the +last request, and that toggling it back to 0 returns FALSE. +--EXTENSIONS-- +curl +--FILE-- + +--EXPECTF-- +With CURLINFO_HEADER_OUT=1: +GET /get.inc?test=method HTTP/1.1 +Host: localhost:%d +%s +Request-num: 1 +--- +With CURLINFO_HEADER_OUT=0: +bool(false) diff --git a/ext/curl/tests/curl_setopt_CURLOPT_FNMATCH_FUNCTION.phpt b/ext/curl/tests/curl_setopt_CURLOPT_FNMATCH_FUNCTION.phpt new file mode 100644 index 000000000000..94196842160e --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_FNMATCH_FUNCTION.phpt @@ -0,0 +1,41 @@ +--TEST-- +Curl option CURLOPT_FNMATCH_FUNCTION +--EXTENSIONS-- +curl +--SKIPIF-- + +--FILE-- + +--EXPECT-- +The list of Debian mirror sites is available here: https://www.debian.org/mirror/list +bool(true) +bool(true) diff --git a/ext/curl/tests/curl_setopt_CURLOPT_MAXFILESIZE_LARGE.phpt b/ext/curl/tests/curl_setopt_CURLOPT_MAXFILESIZE_LARGE.phpt new file mode 100644 index 000000000000..72064be824f0 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_MAXFILESIZE_LARGE.phpt @@ -0,0 +1,54 @@ +--TEST-- +Curl option CURLOPT_MAXFILESIZE_LARGE +--DESCRIPTION-- +Test CURLOPT_MAXFILESIZE_LARGE with values that exceed, do not exceed, and +disable the limit, as well as a negative value that triggers an error. +--EXTENSIONS-- +curl +--FILE-- + +--EXPECTF-- +Body larger than CURLOPT_MAXFILESIZE_LARGE +bool(false) +bool(true) +Body smaller than CURLOPT_MAXFILESIZE_LARGE +int(25) +Limit disabled by setting CURLOPT_MAXFILESIZE_LARGE to 0 +int(25) +Negative value for CURLOPT_MAXFILESIZE_LARGE +bool(false) +bool(true) +Negative value not set, CURLOPT_MAXFILESIZE_LARGE is still 0 +int(25) diff --git a/ext/curl/tests/curl_setopt_CURLOPT_POSTREDIR.phpt b/ext/curl/tests/curl_setopt_CURLOPT_POSTREDIR.phpt new file mode 100644 index 000000000000..ff7cebdb4c15 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_POSTREDIR.phpt @@ -0,0 +1,59 @@ +--TEST-- +Curl option CURLOPT_POSTREDIR +--DESCRIPTION-- +Verify that CURLOPT_POSTREDIR controls whether POST data is retained on +301, 302, and 303 redirects. By default libcurl turns POST into GET on +301, 302, and 303. Setting the appropriate bit in CURLOPT_POSTREDIR +keeps the POST method and body. +--EXTENSIONS-- +curl +--FILE-- + +--EXPECT-- +code: 301; option NULL: string(0) "" +code: 302; option NULL: string(0) "" +code: 303; option NULL: string(0) "" +code: 301; option 1: string(29) "postdata was kept in redirect" +code: 302; option 1: string(0) "" +code: 303; option 1: string(0) "" +code: 301; option 2: string(0) "" +code: 302; option 2: string(29) "postdata was kept in redirect" +code: 303; option 2: string(0) "" +code: 301; option 4: string(0) "" +code: 302; option 4: string(0) "" +code: 303; option 4: string(29) "postdata was kept in redirect" +code: 301; option 7: string(29) "postdata was kept in redirect" +code: 302; option 7: string(29) "postdata was kept in redirect" +code: 303; option 7: string(29) "postdata was kept in redirect" +code: 301; option 0: string(0) "" +code: 302; option 0: string(0) "" +code: 303; option 0: string(0) "" diff --git a/ext/curl/tests/curl_setopt_CURLOPT_SSH_HOSTKEYFUNCTION.phpt b/ext/curl/tests/curl_setopt_CURLOPT_SSH_HOSTKEYFUNCTION.phpt new file mode 100644 index 000000000000..9bb6f0104cdf --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_SSH_HOSTKEYFUNCTION.phpt @@ -0,0 +1,30 @@ +--TEST-- +Curl option CURLOPT_SSH_HOSTKEYFUNCTION +--EXTENSIONS-- +curl +--SKIPIF-- += 7.84.0"); +} +?> +--FILE-- + +--EXPECT-- +bool(false) +string(49) "SSL peer certificate or SSH remote key was not OK" diff --git a/ext/curl/tests/curl_setopt_CURLOPT_WRITEHEADER.phpt b/ext/curl/tests/curl_setopt_CURLOPT_WRITEHEADER.phpt new file mode 100644 index 000000000000..1358307f91e1 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_WRITEHEADER.phpt @@ -0,0 +1,37 @@ +--TEST-- +Curl option CURLOPT_WRITEHEADER +--DESCRIPTION-- +Test writing HTTP response headers to a file using CURLOPT_WRITEHEADER. +--EXTENSIONS-- +curl +--FILE-- + +--CLEAN-- + +--EXPECTF-- +HTTP/1.1 200 OK +Host: localhost:%d +Date: %s +Connection: close +X-Powered-By: PHP/%s +Content-Type: text/plain;charset=utf-8 diff --git a/ext/curl/tests/responder/get.inc b/ext/curl/tests/responder/get.inc index 2ef1e4a89dd3..f84d4b62858f 100644 --- a/ext/curl/tests/responder/get.inc +++ b/ext/curl/tests/responder/get.inc @@ -49,7 +49,9 @@ case 'redirect': // A 307 preserves the method and body, so libcurl must rewind the upload // (via CURLOPT_SEEKFUNCTION) before resending it to the new location. - header('Location: /get.inc?test=input', true, 307); + $target = $_GET['target'] ?? 'input'; + $code = $_GET['code'] ?? 307; + header('Location: /get.inc?test=' . $target, true, $code); break; default: echo "Hello World!\n";