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..198dc4767228 --- /dev/null +++ b/ext/curl/tests/curl_errors.phpt @@ -0,0 +1,108 @@ +--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..1627c03f2ba2 --- /dev/null +++ b/ext/curl/tests/curl_getinfo_CURLINFO_HEADER_OUT.phpt @@ -0,0 +1,39 @@ +--TEST-- +curl_getinfo CURLINFO_HEADER_OUT +--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..c3136f958835 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_FNMATCH_FUNCTION.phpt @@ -0,0 +1,43 @@ +--TEST-- +Curl option CURLOPT_FNMATCH_FUNCTION +--EXTENSIONS-- +curl +--SKIPIF-- + +--FILE-- + +--EXPECT-- +For sale: baby shoes, never worn. +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..8e12e8b9a780 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_MAXFILESIZE_LARGE.phpt @@ -0,0 +1,60 @@ +--TEST-- +Curl option CURLOPT_MAXFILESIZE_LARGE +--SKIPIF-- += 8.4.0"); +} +?> +--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..71142d807bc5 --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_POSTREDIR.phpt @@ -0,0 +1,54 @@ +--TEST-- +Curl option CURLOPT_POSTREDIR +--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..819d7a0c98de --- /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) +bool(true) 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..8dbc80b4178c --- /dev/null +++ b/ext/curl/tests/curl_setopt_CURLOPT_WRITEHEADER.phpt @@ -0,0 +1,35 @@ +--TEST-- +Curl option 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"; diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index 2c7a3a8a5643..b8ac8893ea0d 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -329,7 +329,7 @@ if ($pid) { } }elseif (preg_match('/^RETR ([\/]*[\w\h]+)/', $buf, $matches)) { if(!empty($pasv)){ - ; + $fs = $pasvs; } else if (!$fs = stream_socket_client("tcp://$host:$port")) { fputs($s, "425 Can't open data connection\r\n"); @@ -449,6 +449,8 @@ if ($pid) { if (empty($bug73457)) { $pasvs = stream_socket_accept($soc,10); + } else { + $pasvs = null; } } elseif (preg_match('/^EPSV/', $buf, $matches)) { @@ -495,7 +497,40 @@ if ($pid) { fputs($s, "226 Transfer complete\r\n"); }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { fputs($s, "425 Error establishing connection\r\n"); - + }elseif (preg_match('/^LIST\s*$/', $buf, $matches)) { + if (empty($pasv)) { + fputs($s, "150 File status okay; about to open data connection\r\n"); + if (!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + } else { + fputs($s, "125 Data connection already open; transfer starting.\r\n"); + $fs = $pasvs; + } + fputs($fs, + "drwxr-xr-x 1 owner group 0 Jan 01 00:00 .\r\n" . + "drwxr-xr-x 1 owner group 0 Jan 01 00:00 ..\r\n" . + "drwxr-xr-x 1 owner group 0 Jan 01 00:00 www\r\n" . + "drwxr-xr-x 1 owner group 0 Jan 01 00:00 emptydir\r\n" . + "-rw-r--r-- 1 owner group 33 Jan 01 00:00 file1\r\n" . + "-rw-r--r-- 1 owner group 8 Jan 01 00:00 file\r\n" . + "-rw-r--r-- 1 owner group 35 Jan 01 00:00 a story\r\n" . + "-rw-r--r-- 1 owner group 14 Jan 01 00:00 binary data\r\n" . + "-rw-r--r-- 1 owner group 13 Jan 01 00:00 fget\r\n" . + "-rw-r--r-- 1 owner group 5 Jan 01 00:00 fgetresume\r\n" . + "-rw-r--r-- 1 owner group 5368709120 Jan 01 00:00 largefile\r\n" . + "-rw-r--r-- 1 owner group 5100 Jan 01 00:00 mediumfile\r\n" . + "-rw-r--r-- 1 owner group 1 Jan 01 00:00 fget_large\r\n" . + "-rw-r--r-- 1 owner group 4107 Jan 01 00:00 crlf_boundary\r\n" . + "-rw-r--r-- 1 owner group 4096 Jan 01 00:00 bare_cr\r\n" . + "-rw-r--r-- 1 owner group 6 Jan 01 00:00 trailing_cr\r\n" . + "-rw-r--r-- 1 owner group 10 Jan 01 00:00 gh10521\r\n" . + "-rw-r--r-- 1 owner group 10 Jan 01 00:00 pasv\r\n" . + "-rw-r--r-- 1 owner group 10 Jan 01 00:00 bug73457\r\n" + ); + fclose($fs); + fputs($s, "226 Closing data Connection.\r\n"); }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { $GLOBALS['rest_pos'] = $matches[1]; fputs($s, "350 OK\r\n");