php-src/ext/curl/tests/curl_setopt_basic002.phpt

53 lines
1.2 KiB
Plaintext
Raw Normal View History

2009-07-03 00:04:54 +00:00
--TEST--
curl_setopt basic tests with CURLOPT_STDERR.
--CREDITS--
Paul Sohier
#phptestfest utrecht
--SKIPIF--
2011-09-07 10:34:58 +00:00
<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
2009-07-03 00:04:54 +00:00
--FILE--
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
$temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR');
2009-07-03 00:04:54 +00:00
$handle = fopen($temp_file, 'w');
$url = "{$host}/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $handle);
$curl_content = curl_exec($ch);
fclose($handle);
unset($handle);
2011-08-31 22:12:53 +00:00
var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
@unlink($temp_file);
2009-07-03 00:04:54 +00:00
ob_start(); // start output buffering
$handle = fopen($temp_file, 'w');
2009-07-03 00:04:54 +00:00
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
curl_setopt($ch, CURLOPT_STDERR, $handle);
2009-07-03 00:04:54 +00:00
$data = curl_exec($ch);
ob_end_clean();
fclose($handle);
unset($handle);
2011-08-31 22:12:53 +00:00
var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
2009-07-03 00:04:54 +00:00
@unlink($temp_file);
curl_close($ch);
2009-07-03 00:04:54 +00:00
?>
--EXPECTF--
*** Testing curl_setopt with CURLOPT_STDERR
string(%d) "%S"
string(%d) "%S"
* Closing connection #%d