curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$copy = curl_copy_handle($ch);
- curl_close($ch);
-
- $curl_content = curl_exec($copy);
+
+ var_dump( curl_exec($ch) );
+ var_dump( curl_exec($copy) );
+
+ curl_close($ch); // can not close original handle before curl_exec($copy) since it causes char * inputs to be invalid (see also: http://curl.haxx.se/libcurl/c/curl_easy_duphandle.html)
curl_close($copy);
- var_dump( $curl_content );
?>
===DONE===
--EXPECTF--
*** Testing curl copy handle with User Agent ***
string(9) "cURL phpt"
-===DONE===
\ No newline at end of file
+string(9) "cURL phpt"
+===DONE===
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("Hello" => "World", "Foo" => "Bar", "Person" => "John Doe"));
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // Disable Expect: header (lighttpd does not support it :)
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$copy = curl_copy_handle($ch);
// start testing
echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
-$temp_file = tempnam(sys_get_temp_dir(), '');
+$temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR');
+
$handle = fopen($temp_file, 'w');
$url = "{$host}/";
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $handle);
-
$curl_content = curl_exec($ch);
-fclose($handle);
-var_dump( curl_error($ch) );
-var_dump( file_get_contents($temp_file));
-
-@unlink ($temp_file);
-$handle = fopen($temp_file, 'w');
+fclose($handle);
+unset($handle);
+var_dump( file_get_contents($temp_file) );
+@unlink($temp_file);
ob_start(); // start output buffering
-curl_setopt($ch, CURLOPT_VERBOSE, 1);
-curl_setopt($ch, CURLOPT_STDERR, $handle);
+$handle = fopen($temp_file, 'w');
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
-
+curl_setopt($ch, CURLOPT_STDERR, $handle);
$data = curl_exec($ch);
-fclose($handle);
ob_end_clean();
-var_dump(file_get_contents($temp_file));
-curl_close($ch);
+fclose($handle);
+unset($handle);
+var_dump( file_get_contents($temp_file) );
@unlink($temp_file);
+
+curl_close($ch);
+
?>
--EXPECTF--
*** Testing curl_setopt with CURLOPT_STDERR
-string(%d) "%s%w"
string(%d) "%S"
string(%d) "%S"