|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15491 Curl and PHP_CURL_RETURN wrong behavior
Submitted: 2002-02-10 14:54 UTC Modified: 2002-03-03 11:30 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: hans dot petrich at tronic-media dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 4.1.1 OS: Linux 2.4 (RedHat 7.2)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hans dot petrich at tronic-media dot com
New email:
PHP Version: OS:


 [2002-02-10 14:54 UTC] hans dot petrich at tronic-media dot com
i still working with the PHP's curl functions (PHP 4.1.1) .
When call curl_exec() and CURLOPT_RETURNTRANSFER ist set (to 1) via
curl_opt() - php quit with a Segfault when curl_exec() receive nothink from
the Server.
After i get the last CVS curl.c (V 1.105) the Segfault was fixed but php
return 1 (RETURN_TRUE)  in such situation.

I have write a small (and perhaps dirty) hack witch will fix this. Perhaps
the author of curl.c can update curl.c in the CVS to avoid the wrong return
Thank u, PHP is great.
Hans-Juergen Petrich

/* curl.c */

/* {{{ proto bool curl_exec(int ch)
   Perform a CURL session */
 zval      **zid;
 php_curl   *ch;
 CURLcode    error;

 if (ZEND_NUM_ARGS() != 1 ||
     zend_get_parameters_ex(1, &zid) == FAILURE) {
 ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);

 error = curl_easy_perform(ch->cp);
 if (error != CURLE_OK) {
  if (ch->handlers->write->buf.len > 0)
  SAVE_CURL_ERROR(ch, error);

    if (ch->handlers->write->method == PHP_CURL_RETURN) {
        if (ch->handlers->write->buf.len <= 0)
        if (ch->handlers->write->type != PHP_CURL_BINARY)
ch->handlers->write->buf.len, 0);

/* }}} */


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-11 18:25 UTC] jacob at siamesecode dot com
This is the same bug I reported in report #15307, though I didn't provide a fix like Hans did. Way to go!
 [2002-02-11 18:51 UTC] hans dot petrich at tronic-media dot com
Its not exactly the same bug described in #15307.
Bug #15307 was fixed in the cvs of curl.c (V 1.103)

... i get the last CVS curl.c (V 1.105) the Segfault was fixed but
returns 1 (RETURN_TRUE)  in such situation.

Hans-J?rgen Petrich
 [2002-03-03 11:30 UTC]
This is the correct behaviour, it signifies that the request was successfully made, whether or not the server returns data is not a cURL thing...
 [2002-03-03 15:18 UTC] hans dot petrich at tronic-media dot com
mhhh...what i mean is:
If CURLOPT_RETURNTRANSFER set to 1 curl_exec() should return the transfered content instead of printing it out directly (see
In this case (when CURLOPT_RETURNTRANSFER=1) curl_exec() should return exactly the transfered content and not the statuscode

Have a look at the example:

	$url	=	'';#Its an empty html document
	$ch 	= 	curl_init($url);
	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1);
	$content= curl_exec ( $ch);#returns 1, should return nothink
	echo "content of $url :$content"; 
	echo "\n";
	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 0);
	echo "content of $url :";
	curl_exec ( $ch);# print out nothink - right
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 21:01:28 2024 UTC