Bug #72864 [NEW]: CURLOPT_READFUNCTION waits $fp readable only once.
| From: | ryosuke_i_628 at yahoo dot co dot jp | Date: | Wed, 17 Aug 2016 10:14:09 +0000 |
| Subject: | Bug #72864 [NEW]: CURLOPT_READFUNCTION waits $fp readable only once. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203345@lists.php.net to get a copy of this message | ||
From: ryosuke_i_628 at yahoo dot co dot jp
Operating system: OSX 10.11.5
PHP version: 7.0.9
Package: cURL related
Bug Type: Bug
Bug description:CURLOPT_READFUNCTION waits $fp readable only once.
Description:
------------
CURLOPT_READFUNCTION waits $fp readable only once.
Is this a bug? Or by design?
Test script:
---------------
<?php
/*
mkfifo /path/to/fifo
*/
$fp = fopen('/path/to/fifo', 'rb');
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'example.com',
CURLOPT_PUT => true,
CURLOPT_INFILE => $fp,
CURLOPT_INFILESIZE => 5,
CURLOPT_READFUNCTION => function ($ch, $fp, $max) {
$buf = fread($fp, 1);
var_dump($buf);
return $buf;
},
]);
curl_exec($ch);
/*
We can verify that CURLOPT_READFUNCTION invocation is blocked.
However, after we executed the following command...
printf "a" > /path/to/fifo
*/
?>
Expected result:
----------------
string(1) "a"
...then invocation should be blocked again
Actual result:
--------------
string(1) "a"
string(0) ""
...wtf!?
--
Edit bug report at https://bugs.php.net/bug.php?id=72864&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72864&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72864&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72864&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72864&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72864&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72864&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72864&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72864&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72864&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72864&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72864&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72864&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72864&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72864&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72864&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72864&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72864&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72864&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72864&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72864&r=mysqlcfg