php.net |  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: -
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
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!?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 05:01:26 2019 UTC