php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29591 odd behavior changes in php > 4.3.4 by CURLOPT_RETURNTRANSFER
Submitted: 2004-08-09 19:30 UTC Modified: 2004-10-04 04:10 UTC
From: r-two at gmx dot de Assigned:
Status: Not a bug Package: cURL related
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: r-two at gmx dot de
New email:
PHP Version: OS:

 

 [2004-08-09 19:30 UTC] r-two at gmx dot de
Description:
------------
I dont know exactly if this is a bug or just misentry in the Documentation. So I simply start with the code responsible for this behavior.

curl.h line 848:
case CURLOPT_RETURNTRANSFER:
   convert_to_long_ex(zvalue);
   if (Z_LVAL_PP(zvalue)) {
	ch->handlers->write->method = PHP_CURL_RETURN;
   } else {
	ch->handlers->write->method = PHP_CURL_STDOUT;
   }	
break; 

as you can see, the write->method is set to STDOUT if the value is 0. This could be very perplexing if the write->method has previously change. (with CURLOPT_FILE in my example)

a simply solution would be to cut the else tree and just change the wirte->method by an none zero value.

a better one could be to rewrite the curl ext in a way that multible write methods can be handeled.

Surely this is not a "real" bug, but either the documentation or the code is wrong and in my opinion it's the code.


Kind regards,
Martin Hoch

Reproduce code:
---------------
<?php
        $ch = curl_init("http://www.php.net/");
        $fp = fopen("example_homepage.txt", "w");
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
?>


Expected result:
----------------
As descripted above i expected the curl output in the file...

Actual result:
--------------
...but it occurs in stdout.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-04 04:10 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Output options are exclusive. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC