Bug #10860: final char deleted with CURLOPT_RETURNTRANSFER
| From: | sr2899 at hotmail dot com | Date: | Mon, 14 May 2001 20:17:03 +0000 |
| Subject: | Bug #10860: final char deleted with CURLOPT_RETURNTRANSFER | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-55237@lists.php.net to get a copy of this message | ||
From: sr2899@hotmail.com
Operating system: Linux
PHP version: 4.0.4pl1
PHP Bug Type: cURL related
Bug description: final char deleted with CURLOPT_RETURNTRANSFER
I noticed a while ago that CURLOPT_RETURNTRANSFER added trailing null chars to the end of html
pages, which seemed odd, but didn't seem like a bug. Then I noticed that on binary files, in
fact what it does is REPLACE the trailing char with a null char.
Oddly, setting CURLOPT_HEADER to 1 seems to fix the problem.
<?
$f = fopen('/tmp/bla1','w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.php.net/gifs/small_submit.gif");
curl_setopt($ch, CURLOPT_FILE,$f);
curl_exec($ch);
curl_close($ch);
rewind($f);
fclose($f);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.php.net/gifs/small_submit.gif");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
$f = fopen('/tmp/bla2','w');
$ret = fwrite($f,$ret,strlen($ret));
fclose($f);
system('diff /tmp/bla2 /tmp/bla1');
?>
--
Edit Bug report at: http://bugs.php.net/?id=10860&edit=1