|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72864 CURLOPT_READFUNCTION waits $fp readable only once.
Submitted: 2016-08-17 10:14 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ryosuke_i_628 at yahoo dot co dot jp Assigned:
Status: Open Package: cURL related
PHP Version: 7.0.9 OS: OSX 10.11.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ryosuke_i_628 at yahoo dot co dot jp
New email:
PHP Version: OS:


 [2016-08-17 10:14 UTC] ryosuke_i_628 at yahoo dot co dot jp
CURLOPT_READFUNCTION waits $fp readable only once.
Is this a bug? Or by design?

Test script:


mkfifo /path/to/fifo


$fp = fopen('/path/to/fifo', 'rb');

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => '',
    CURLOPT_PUT => true,
    CURLOPT_INFILE => $fp,
    CURLOPT_READFUNCTION => function ($ch, $fp, $max) {
        $buf = fread($fp, 1);
        return $buf;


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) ""!?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-17 10:22 UTC] ryosuke_i_628 at yahoo dot co dot jp
Note that:

- cURL actually sends "Content-Length: 5"
- Additional printf calls after the first call are completely ignored
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 22 10:12:42 2021 UTC