php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38637 curl_exec return true with curl_copy_handle
Submitted: 2006-08-29 01:06 UTC Modified: 2006-08-29 22:27 UTC
From: waax at yahoo dot com Assigned: iliaa (profile)
Status: Closed Package: cURL related
PHP Version: 5.1.5 OS: Windows XP SP2
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: waax at yahoo dot com
New email:
PHP Version: OS:

 

 [2006-08-29 01:06 UTC] waax at yahoo dot com
Description:
------------
My script create a default curl handle with some default option along CURLOPT_RETURNTRANSFER that is used as a "template". This default curl handle is then copied with curl_copy_handle for all connections i need to create.

I expected each call of curl_exec to return the content downloaded. 

Instead, each call return bool(true).

libcurl/7.14.0 OpenSSL/0.9.8a zlib/1.2.3



Reproduce code:
---------------
<?php
// Creating default Curl Handler
$ch_default = curl_init();

// Setting some options
curl_setopt($ch_default, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch_default, CURLOPT_AUTOREFERER, true);
curl_setopt($ch_default, CURLOPT_RETURNTRANSFER, true);

$ch2 = curl_copy_handle($ch_default);
// Uncomment to see the difference
// $ch2 = curl_init();
// curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch2, CURLOPT_URL, "http://yahoo.com");

$res = curl_exec($ch2);

var_dump($res);
?>

Expected result:
----------------
string(10074) "<html><head>
<title>Yahoo!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l r (cz 1 lz 1 nz 1 oz 1 vz 1) gen true for "http://www.yahoo.com" r (cz1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l r (n 0 s 0 v 0 l0) gen true for "http://www.yahoo.com" r (n 0 s 0 v 0 l 0))'>
[TRUNCATED]

Actual result:
--------------
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-29 08:29 UTC] tony2001@php.net
Ilia, please take a look at it.
This patch fixes it: http://tony2001.phpclub.net/dev/tmp/bug38637.diff
But the problem is that it re-sets options that could be changed by the user, so we something smarter here..
So, the idea is that currently all buffers point to the original handle, even though we're executing the copy.
 [2006-08-29 17:11 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2006-08-29 22:27 UTC] waax at yahoo dot com
Thanks to you!
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 11:03:38 2021 UTC