Bug #72864 [Com]: CURLOPT_READFUNCTION waits $fp readable only once.
| From: | ryosuke_i_628 at yahoo dot co dot jp | Date: | Wed, 17 Aug 2016 10:22:50 +0000 |
| Subject: | Bug #72864 [Com]: CURLOPT_READFUNCTION waits $fp readable only once. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203346@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72864&edit=1
ID: 72864
Comment by: ryosuke_i_628 at yahoo dot co dot jp
Reported by: ryosuke_i_628 at yahoo dot co dot jp
Summary: CURLOPT_READFUNCTION waits $fp readable only once.
Status: Open
Type: Bug
Package: cURL related
Operating System: OSX 10.11.5
PHP Version: 7.0.9
Block user comment: N
Private report: N
New Comment:
Note that:
- cURL actually sends "Content-Length: 5"
- Additional printf calls after the first call are completely ignored
Previous Comments:
------------------------------------------------------------------------
[2016-08-17 10:14:08] ryosuke_i_628 at yahoo dot co dot jp
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 this bug report at https://bugs.php.net/bug.php?id=72864&edit=1