ID:               49178
 Comment by:       phpspam at ethaniel dot com
 Reported By:      moricio at gmail dot com
 Status:           No Feedback
 Bug Type:         cURL related
 Operating System: Windows 2003 Server SP2
 PHP Version:      5.2.10
 New Comment:

This has been fixed in 5.2.11


Previous Comments:
------------------------------------------------------------------------

[2009-10-11 08:49:08] phpspam at ethaniel dot com

I confirm this on PHP 5.2.10 (cli) running on Freebsd 7.2.

------------------------------------------------------------------------

[2009-08-14 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2009-08-06 13:19:28] j...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2009-08-06 12:21:03] moricio at gmail dot com

Description:
------------
Hi.

I have a PHP app where I generate a PDF file, using jasperreports, and

then mail this file to a subscriber. I use curl and the CURLOPT_FILE 
option to get the pdf file. As soon as I finish getting the file, it 
reports a size that is always an exact multiple of 4Kbytes, even when 
the file is bigger than what PHP reports.


Reproduce code:
---------------
Code with error is ...
--
<?php
$ch = curl_init("http://www.google.com";);
$tmpfname = tempnam(sys_get_temp_dir(), "IPV");
$fpOutput = fopen($tmpfname, "wb");

curl_setopt($ch, CURLOPT_FILE, $fpOutput);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fpOutput);
echo "filesize: $tmpfname: " . filesize($tmpfname) . "\n";
?>

--

Code without error is ...
--
<?php
$tmpfname = tempnam(sys_get_temp_dir(), "IPV");
$fpOutput = fopen($tmpfname, "wb");

$ch = curl_init("http://www.google.com";);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
curl_exec($ch);
curl_close($ch);

fclose($fpOutput);

echo "filesize: $tmpfname: " . filesize($tmpfname) . "\n";
die();

function read_body($ch, $string)
{
        global $fpOutput;

        $length = strlen($string);
        if (fwrite($fpOutput, $string) === FALSE) {
                echo "Cannot write to file";
                die();
        }
        return $length;
}
?>


Expected result:
----------------
The second piece of code reported in this bug report gives the correct

file size.

The first piece of code saves the file with the correct size but
doesn't 
report it correctly.

This was not happening until I upgraded to PHP 5.2.10 from a previous 
version that I don't remember. :(

Hope you can find inside what is going on.

Best regards and thanks for a great piece of software.

Mauricio Ramirez


Actual result:
--------------
The first piece of code reports 4096 bytes for the google.com page.

The second piece of code reports (today!) 6672 bytes which is the right

size.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49178&edit=1

Reply via email to