Bug #72092 [Opn->Ver]: CURLOPT_FILE is rewinded depending on stream type
| From: | mike@php.net | Date: | Tue, 26 Mar 2019 17:28:54 +0000 |
| Subject: | Bug #72092 [Opn->Ver]: CURLOPT_FILE is rewinded depending on stream type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220202@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72092&edit=1
ID: 72092
Updated by: mike@php.net
Reported by: bugs dot php dot net at ss dot st dot tc
Summary: CURLOPT_FILE is rewinded depending on stream type
-Status: Open
+Status: Verified
Type: Bug
Package: cURL related
Operating System: Linux
PHP Version: 7.0.5
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2019-03-26 16:29:50] mike@php.net
Probably fixable by upgrading internals to streams instead of stdio.
Related to Bug #76268 and Bug #70693
------------------------------------------------------------------------
[2016-08-03 15:49:19] vonubrog at gmail dot com
Same here with PHP 7.0.9 and 5.4.45. Such an annoying inconsistency :(
------------------------------------------------------------------------
[2016-04-24 06:41:21] bugs dot php dot net at ss dot st dot tc
Description:
------------
When using CURLOPT_FILE, file position indicator stays in the end when the handle is a temporary
stream. However the indicator is rewinded to 0 when the handle is a regular file (which seems to be
a wrong behaviour).
Tested in PHP 7.0.5 and 5.6.20.
Test script:
---------------
<?php
function test($filename) {
echo $filename, PHP_EOL;
$fh = fopen($filename, 'w');
$curl = curl_init('http://php.net/');
curl_setopt($curl, CURLOPT_FILE, $fh);
curl_exec($curl);
echo ' fstat size: ', fstat($fh)['size'], PHP_EOL;
echo ' ftell: ', ftell($fh), PHP_EOL;
}
test('regular-file.tmp');
test('php://temp');
Expected result:
----------------
regular-file.tmp
fstat size: 19371
ftell: 19371
php://temp
fstat size: 19371
ftell: 19371
Actual result:
--------------
regular-file.tmp
fstat size: 19371
ftell: 0
php://temp
fstat size: 19371
ftell: 19371
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72092&edit=1