PHP cURL catch verbose output with custom stream wrapper using CURLOPT_STDERR option

Viewed 17

I am trying to catch cURL verbose output with custom stream wrapper.

Something among following lines

stream_register_wrapper('myvars', 'MyWrapper');

$fp = fopen('myvars//:curl-verbose', 'r+');

curl_setopt_array($ch, [
    CURLOPT_VERBOSE => true,
    CRULOPT_STDERR => $fp;
];

When I run the script I end up with following error:

TypeError: curl_setopt_array(): supplied resource is not a valid File-Handle

Same error is thrown with built in streams php://memory and php://temp

Used PHP version is 8.1.9

Setting CURLOPT_STDERR to opened file handle works, but my intention is to handle verbose output without creating temprorary files.

Could it be it is simply impossible with current PHP cURL implementation?

0 Answers
Related