Bug #80518 [NEW]: win7
| From: | malacca42 at gmail dot com | Date: | Tue, 15 Dec 2020 09:19:20 +0000 |
| Subject: | Bug #80518 [NEW]: win7 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231091@lists.php.net to get a copy of this message | ||
From: malacca42 at gmail dot com
Operating system: windows
PHP version: 8.0.0
Package: cURL related
Bug Type: Bug
Bug description:win7
Description:
------------
CURLOPT_READFUNCTION stream can't rewind
Test script:
---------------
$file = __DIR__.'/payload';
$fp = fopen($file, 'r');
$ch = curl_init('http://localhost/server.php');
curl_setopt_array($ch, [
CURLOPT_VERBOSE => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_FOLLOWLOCATION => true, // follow location
CURLOPT_UPLOAD => true,
CURLOPT_INFILESIZE => filesize($file),
CURLOPT_READFUNCTION => function ($ch, $fd, $length) use ($fp) {
return fread($fp, $length);
},
]);
curl_exec($ch);
curl_close($ch);
----------
the "server.php" is very simple
if (isset($_GET['n'])) {
echo file_get_contents('php://input');
} else {
Header("Location: sever.php?n=1");
http_response_code(307);
}
Expected result:
----------------
server can read payload after redirect
as RFC, entity body will resend after response 307 redirect
https://tools.ietf.org/html/rfc7231#section-6.4
but CURLOPT_READFUNCTION function only read once
maybe php lost CURLOPT_SEEKFUNCTION option
https://curl.se/libcurl/c/CURLOPT_SEEKFUNCTION.html
One more thing:
this is very very slow using php8, php7 is fast
Actual result:
--------------
got issue
"necessary data rewind wasn't possible"
--
Edit bug report at https://bugs.php.net/bug.php?id=80518&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80518&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80518&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80518&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80518&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80518&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80518&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80518&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80518&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80518&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80518&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80518&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80518&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80518&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80518&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80518&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80518&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80518&r=mysqlcfg