note 102591 deleted from function.curl-copy-handle by danbrown

[email protected] Wed, 23 Feb 2011 07:48:33 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: lxyfirst at 163 dot com 

----

There is a crash when use cookie with curl_copy_handle as below:
$url = "http://www.google.com.hk" ;
$cookie_file = tempnam("/tmp","curl") ;
$curl_handle= curl_init() ;
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $cookie_file);

curl_setopt($curl_handle, CURLOPT_URL, $url);
$return_data = curl_exec($curl_handle);
$curl_tmp = curl_copy_handle($curl_handle);
curl_close($curl_handle) ;
$cookie_data = file_get_contents($cookie_file) ;

var_dump($cookie_data) ; //first request success

$curl_handle = $curl_tmp ;
curl_setopt($curl_handle, CURLOPT_URL, $url);
$return_data = curl_exec($curl_handle);  //second request crash here