import curl tests

Not very good coverage here, but @sgolemon predicted that.
Esse commit está contido em:
ptarjan
2013-04-18 17:02:07 -07:00
commit de Sara Golemon
commit 4c77061e3f
147 arquivos alterados com 2244 adições e 1 exclusões
+30
Ver Arquivo
@@ -0,0 +1,30 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
var_dump(curl_exec($ch));
$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
var_dump(curl_exec($ch));
$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
var_dump(curl_exec($ch));
$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;type=text/plain;filename=foo.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
var_dump(curl_exec($ch));
$params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt;filename=foo.txt;type=text/plain');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
var_dump(curl_exec($ch));
curl_close($ch);
?>
@@ -0,0 +1,5 @@
string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"
string(%d) "foo.txt|text/plain"
+18
Ver Arquivo
@@ -0,0 +1,18 @@
<?php
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_URL, getenv('PHP_CURL_HTTP_REMOTE_SERVER'));
fclose($fp); // <-- premature close of $fp caused a crash!
curl_exec($ch);
curl_close($ch);
echo "Ok\n";
?><?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?>
@@ -0,0 +1,3 @@
HipHop Warning: %a
%A
Ok
@@ -0,0 +1,54 @@
<?php
function checkForClosedFilePointer($curl_option, $description) {
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$ch1 = curl_init();
$ch2 = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => 1,
$curl_option => $fp,
CURLOPT_URL => getenv("PHP_CURL_HTTP_REMOTE_SERVER")
);
// we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly
if (CURLOPT_STDERR == $curl_option) {
$options[CURLOPT_VERBOSE] = 1;
}
if (CURLOPT_INFILE == $curl_option) {
$options[CURLOPT_UPLOAD] = 1;
}
curl_setopt_array($ch1, $options);
curl_setopt_array($ch2, $options);
fclose($fp); // <-- premature close of $fp caused a crash!
$mh = curl_multi_init();
curl_multi_add_handle($mh, $ch1);
curl_multi_add_handle($mh, $ch2);
$active = 0;
do {
curl_multi_exec($mh, $active);
} while ($active > 0);
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
echo "Ok for $description\n";
}
$options_to_check = array(
"CURLOPT_STDERR", "CURLOPT_WRITEHEADER", "CURLOPT_FILE", "CURLOPT_INFILE"
);
foreach($options_to_check as $option) {
checkForClosedFilePointer(constant($option), $option);
}
?><?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?>
@@ -0,0 +1,15 @@
HipHop Warning: %a
HipHop Warning: %a
%A
Ok for CURLOPT_STDERR
%A
HipHop Warning: %a
HipHop Warning: %a
Ok for CURLOPT_WRITEHEADER
HipHop Warning: %a
HipHop Warning: %a
%A
Ok for CURLOPT_FILE
HipHop Warning: %a
HipHop Warning: %a
Ok for CURLOPT_INFILE
+35
Ver Arquivo
@@ -0,0 +1,35 @@
<?php
/*
* Description : Adds a file which stores the received data from curl_exec();
* Source code : ext/curl/multi.c
* Test documentation: http://wiki.php.net/qa/temp/ext/curl
*/
// Figure out what handler to use
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
if(!empty($host)) {
// Use the set Environment variable
$url = "$host/get.php?test=1";
} else {
// Create a temporary file for the test
$tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
$url = 'file://'. $tempname;
// add the test data to the file
file_put_contents($tempname, "Hello World!\nHello World!");
}
$tempfile = tempnam(sys_get_temp_dir(), 'CURL_FILE_HANDLE');
$ch = curl_init($url);
$fp = fopen($tempfile, "r"); // Opening 'fubar' with the incorrect readonly flag
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
is_file($tempfile) and @unlink($tempfile);
isset($tempname) and is_file($tempname) and @unlink($tempname);
?>
@@ -0,0 +1,3 @@
HipHop Warning: %a
Hello World!
Hello World!
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$ch1 = curl_init();
var_dump($ch1);
var_dump(get_resource_type($ch1));
$ch2 = curl_multi_init();
var_dump($ch2);
var_dump(get_resource_type($ch2));
?>
@@ -0,0 +1,4 @@
resource(%d) of type (curl)
%string|unicode%(4) "curl"
resource(%d) of type (curl_multi)
%string|unicode%(10) "curl_multi"
+43
Ver Arquivo
@@ -0,0 +1,43 @@
<?php
function checkForClosedFilePointer($host, $curl_option, $description) {
$fp = fopen(dirname(__FILE__) . '/bug54798.tmp', 'w+');
$ch = curl_init();
// we also need CURLOPT_VERBOSE to be set to test CURLOPT_STDERR properly
if (CURLOPT_STDERR == $curl_option) {
curl_setopt($ch, CURLOPT_VERBOSE, 1);
}
if (CURLOPT_INFILE == $curl_option) {
curl_setopt($ch, CURLOPT_UPLOAD, 1);
}
curl_setopt($ch, $curl_option, $fp);
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
fclose($fp); // <-- premature close of $fp caused a crash!
curl_exec($ch);
curl_close($ch);
echo "Ok for $description\n";
}
$options_to_check = array(
"CURLOPT_STDERR",
"CURLOPT_WRITEHEADER",
"CURLOPT_FILE",
"CURLOPT_INFILE"
);
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
foreach($options_to_check as $option) {
checkForClosedFilePointer($host, constant($option), $option);
}
?><?php @unlink(dirname(__FILE__) . '/bug54798.tmp'); ?>
@@ -0,0 +1,11 @@
HipHop Warning: %a
* About to connect() %a
* Closing connection #%d
Ok for CURLOPT_STDERR
HipHop Warning: %a
Ok for CURLOPT_WRITEHEADER
HipHop Warning: %a
%a
Ok for CURLOPT_FILE
HipHop Warning: %a
Ok for CURLOPT_INFILE
+27
Ver Arquivo
@@ -0,0 +1,27 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl sending through GET an POST ***' . "\n";
$url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('Hello'=>'World','Foo'=>'Bar',100=>'John Doe'));
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,17 @@
*** Testing curl sending through GET an POST ***
string(203) "array(2) {
["test"]=>
string(7) "getpost"
["get_param"]=>
string(11) "Hello World"
}
array(3) {
["Hello"]=>
string(5) "World"
["Foo"]=>
string(3) "Bar"
[100]=>
string(8) "John Doe"
}
"
===DONE===
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$ch = curl_init();
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
/* Case that should throw an error */
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2));
curl_close($ch);
?>
@@ -0,0 +1,7 @@
bool(true)
HipHop Notice: %a
bool(true)
bool(true)
HipHop Notice: %a
bool(true)
bool(true)
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$ch = curl_init();
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false));
/* Case that should throw an error */
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1));
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2));
curl_close($ch);
?>
@@ -0,0 +1,7 @@
bool(true)
HipHop Notice: %a
bool(true)
bool(true)
HipHop Notice: %a
bool(true)
bool(true)
@@ -0,0 +1,28 @@
<?php
// The URL to POST to
$url = getenv('PHP_CURL_HTTP_REMOTE_SERVER') . '/get.php?test=post';
// Create a temporary file to read the data from
$tempname = tempnam(sys_get_temp_dir(), 'CURL_DATA');
$datalen = file_put_contents($tempname, "hello=world&smurf=blue");
ob_start();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_READDATA, fopen($tempname, 'rb'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:', "Content-Length: {$datalen}"));
if (false === $response = curl_exec($ch)) {
echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
// Clean the temporary file
@unlink($tempname);
@@ -0,0 +1,6 @@
array(2) {
["hello"]=>
string(5) "world"
["smurf"]=>
string(4) "blue"
}
@@ -0,0 +1,29 @@
<?php
/* Prototype : bool curl_exec(resource ch)
* Description: Perform a cURL session
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
$url = "{$host}/get.php?test=get";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$ok = curl_exec($ch);
curl_close($ch);
$curl_content = ob_get_contents();
ob_end_clean();
if($ok) {
var_dump( $curl_content );
} else {
echo "curl_exec returned false";
}
?>
===DONE===
@@ -0,0 +1,4 @@
*** Testing curl_exec() : basic functionality ***
string(25) "Hello World!
Hello World!"
===DONE===
@@ -0,0 +1,25 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n";
$url = "{$host}/get.php?test=get";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,4 @@
*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***
string(25) "Hello World!
Hello World!"
===DONE===
@@ -0,0 +1,27 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl sending through GET an POST ***' . "\n";
$url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,17 @@
*** Testing curl sending through GET an POST ***
string(208) "array(2) {
["test"]=>
string(7) "getpost"
["get_param"]=>
string(11) "Hello World"
}
array(3) {
["Hello"]=>
string(5) "World"
["Foo"]=>
string(3) "Bar"
["Person"]=>
string(8) "John Doe"
}
"
===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl setting referer ***' . "\n";
$url = "{$host}/get.php?test=referer";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.refer.er');
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl setting referer ***
string(19) "http://www.refer.er"
===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl with user agent ***' . "\n";
$url = "{$host}/get.php?test=useragent";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl with user agent ***
string(9) "cURL phpt"
===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); ***' . "\n";
$url = "{$host}/get.php?test=get";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) {
echo 'Data: '.$data;
return strlen ($data);
});
curl_exec($ch);
curl_close($ch);
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); ***
Data: Hello World!
Hello World!===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl with cookie ***' . "\n";
$url = "{$host}/get.php?test=cookie";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, 'foo=bar');
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl with cookie ***
string(3) "bar"
===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl with HTTP/1.0 ***' . "\n";
$url = "{$host}/get.php?test=httpversion";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl with HTTP/1.0 ***
string(8) "HTTP/1.0"
===DONE===
@@ -0,0 +1,26 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo '*** Testing curl with HTTP/1.1 ***' . "\n";
$url = "{$host}/get.php?test=httpversion";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,3 @@
*** Testing curl with HTTP/1.1 ***
string(8) "HTTP/1.1"
===DONE===
@@ -0,0 +1,5 @@
<?php
$ch = curl_init();
var_dump($ch);
?>
===DONE===
@@ -0,0 +1,2 @@
resource(%d) of type (curl)
===DONE===
@@ -0,0 +1,6 @@
<?php
$ch = curl_init();
$info = curl_getinfo($ch);
var_dump($info);
?>
===DONE===
@@ -0,0 +1,43 @@
array(2%d) {
[%u|b%"url"]=>
string(0) ""
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(0)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0)
["namelookup_time"]=>
float(0)
["connect_time"]=>
float(0)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(%f)
["upload_content_length"]=>
float(%f)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
}
===DONE===
@@ -0,0 +1,55 @@
<?php
/* Prototype : bool curl_multi_exec(resource ch)
* Description: Perform a cURL session
* Source code: ext/curl/multi.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
$url = "{$host}/get.php?test=get";
$chs = array(
0 => curl_init(),
1 => curl_init(),
2 => curl_init(),
);
ob_start(); // start output buffering
curl_setopt($chs[0], CURLOPT_URL, $url); //set the url we want to use
curl_setopt($chs[1], CURLOPT_URL, $url); //set the url we want to use
curl_setopt($chs[2], CURLOPT_URL, $url); //set the url we want to use
$mh = curl_multi_init();
// add handlers
curl_multi_add_handle($mh, $chs[0]);
curl_multi_add_handle($mh, $chs[1]);
curl_multi_add_handle($mh, $chs[2]);
$running=null;
//execute the handles
$state = null;
do {
$state = curl_multi_exec($mh, $running);
} while ($running > 0);
//close the handles
curl_multi_remove_handle($mh, $chs[0]);
curl_multi_remove_handle($mh, $chs[1]);
curl_multi_remove_handle($mh, $chs[2]);
curl_multi_close($mh);
$curl_content = ob_get_contents();
ob_end_clean();
if($state === CURLM_OK) {
var_dump( $curl_content );
} else {
echo "curl_exec returned false";
}
?>
===DONE===
@@ -0,0 +1,6 @@
*** Testing curl_exec() : basic functionality ***
string(75) "Hello World!
Hello World!Hello World!
Hello World!Hello World!
Hello World!"
===DONE===
@@ -0,0 +1,58 @@
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Description: Set an option for a cURL transfer
* Source code: ext/curl/interface.c
* Alias to functions:
*/
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
$url = "{$host}/get.php?test=get";
$chs = array(
0 => curl_init(),
1 => curl_init(),
2 => curl_init(),
);
ob_start(); // start output buffering
$options = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
);
curl_setopt_array($chs[0], $options); //set the options
curl_setopt_array($chs[1], $options); //set the options
curl_setopt_array($chs[2], $options); //set the options
$mh = curl_multi_init();
// add handlers
curl_multi_add_handle($mh, $chs[0]);
curl_multi_add_handle($mh, $chs[1]);
curl_multi_add_handle($mh, $chs[2]);
$running=null;
//execute the handles
do {
curl_multi_exec($mh, $running);
} while ($running > 0);
$curl_content = '';
$curl_content .= curl_multi_getcontent($chs[0]);
$curl_content .= curl_multi_getcontent($chs[1]);
$curl_content .= curl_multi_getcontent($chs[2]);
//close the handles
curl_multi_remove_handle($mh, $chs[0]);
curl_multi_remove_handle($mh, $chs[1]);
curl_multi_remove_handle($mh, $chs[2]);
curl_multi_close($mh);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,6 @@
*** Testing curl_exec() : basic functionality ***
%unicode|string%(75) "Hello World!
Hello World!Hello World!
Hello World!Hello World!
Hello World!"
===DONE===
@@ -0,0 +1,14 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
$url = "{$host}/get.php?test=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
var_dump($url == $info);
curl_close($ch);
?>
===DONE===
@@ -0,0 +1,3 @@
Hello World!
Hello World!bool(true)
===DONE===
@@ -0,0 +1,11 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
$url = "{$host}/get.php?test=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));
curl_close($ch);
?>
===DONE===
@@ -0,0 +1,3 @@
Hello World!
Hello World!int(200)
===DONE===
@@ -0,0 +1,11 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
$url = "{$host}/get.php?test=contenttype";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
var_dump(curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
?>
===DONE===
@@ -0,0 +1,2 @@
%unicode|string%(24) "text/plain;charset=utf-8"
===DONE===
@@ -0,0 +1,6 @@
<?php
$ch = curl_init();
curl_close($ch);
var_dump($ch);
?>
===DONE===
@@ -0,0 +1,2 @@
resource(%d) of type (Unknown)
===DONE===
@@ -0,0 +1,22 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Testing curl copy handle with simple GET ***' . "\n";
$url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
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);
curl_close($copy);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,11 @@
*** Testing curl copy handle with simple GET ***
string(106) "array(2) {
["test"]=>
string(7) "getpost"
["get_param"]=>
string(11) "Hello World"
}
array(0) {
}
"
===DONE===
@@ -0,0 +1,23 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Testing curl copy handle with simple POST ***' . "\n";
$url = "{$host}/get.php?test=getpost";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
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);
curl_close($copy);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,15 @@
*** Testing curl copy handle with simple POST ***
string(163) "array(1) {
["test"]=>
string(7) "getpost"
}
array(3) {
["Hello"]=>
string(5) "World"
["Foo"]=>
string(3) "Bar"
["Person"]=>
string(8) "John Doe"
}
"
===DONE===
@@ -0,0 +1,24 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Test curl_copy_handle() after exec() ***' . "\n";
$url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
$copy = curl_copy_handle($ch);
curl_close($ch);
$curl_content_copy = curl_exec($copy);
curl_close($copy);
var_dump( $curl_content_copy );
?>
===DONE===
@@ -0,0 +1,11 @@
*** Test curl_copy_handle() after exec() ***
string(106) "array(2) {
["test"]=>
string(7) "getpost"
["get_param"]=>
string(11) "Hello World"
}
array(0) {
}
"
===DONE===
@@ -0,0 +1,26 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Test curl_copy_handle() after exec() with POST ***' . "\n";
$url = "{$host}/get.php?test=getpost";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$curl_content = curl_exec($ch);
$copy = curl_copy_handle($ch);
curl_close($ch);
$curl_content_copy = curl_exec($copy);
curl_close($copy);
var_dump( $curl_content_copy );
?>
===DONE===
@@ -0,0 +1,15 @@
*** Test curl_copy_handle() after exec() with POST ***
string(163) "array(1) {
["test"]=>
string(7) "getpost"
}
array(3) {
["Hello"]=>
string(5) "World"
["Foo"]=>
string(3) "Bar"
["Person"]=>
string(8) "John Doe"
}
"
===DONE===
@@ -0,0 +1,24 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Testing curl copy handle with User Agent ***' . "\n";
$url = "{$host}/get.php?test=useragent";
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'cURL phpt');
curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
$copy = curl_copy_handle($ch);
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);
?>
===DONE===
@@ -0,0 +1,4 @@
*** Testing curl copy handle with User Agent ***
string(9) "cURL phpt"
string(9) "cURL phpt"
===DONE===
@@ -0,0 +1,24 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
echo '*** Testing curl copy handle with simple POST using array as arguments ***' . "\n";
$url = "{$host}/get.php?test=getpost";
$ch = curl_init();
ob_start(); // start output buffering
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);
curl_close($ch);
$curl_content = curl_exec($copy);
curl_close($copy);
var_dump( $curl_content );
?>
===DONE===
@@ -0,0 +1,15 @@
*** Testing curl copy handle with simple POST using array as arguments ***
string(163) "array(1) {
["test"]=>
string(7) "getpost"
}
array(3) {
["Hello"]=>
string(5) "World"
["Foo"]=>
string(3) "Bar"
["Person"]=>
string(8) "John Doe"
}
"
===DONE===
@@ -0,0 +1,15 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
$url = "{$host}/get.php";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function() { });
$ch2 = curl_copy_handle($ch);
echo curl_exec($ch), PHP_EOL;
unset($ch);
echo curl_exec($ch2);
?>
@@ -0,0 +1,4 @@
Hello World!
Hello World!
Hello World!
Hello World!
@@ -0,0 +1,26 @@
<?php
$ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER'));
$temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp';
if (file_exists($temp_file)) {
unlink($temp_file); // file should not exist before test
}
$handle = fopen($temp_file, 'w');
curl_setopt($ch, CURLOPT_STDERR, $handle);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
fclose($handle); // causes glibc memory error
//unlink($temp_file); // uncomment to test segfault (file not found on iowrite.c)
curl_close($ch);
echo "Closed correctly\n";
?><?php
unlink(dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp');
?>
@@ -0,0 +1,2 @@
* Closing connection #%d
Closed correctly
@@ -0,0 +1,45 @@
<?php
$host = getenv('PHP_CURL_FTP_REMOTE_SERVER');
$username = getenv('PHP_CURL_FTP_REMOTE_USER');
$password = getenv('PHP_CURL_FTP_REMOTE_PASSWD');
// FTP this script to a server
$fp = fopen ( __FILE__ , "r" );
$url = "ftp://$username:$password@$host/test.phpt" ;
$ch = curl_init ();
// enable below to get the output in verbose mode.
// curl_setopt ( $ch , CURLOPT_VERBOSE, 1 );
/* Without enabling SKIP_PASV_IP flag, the following output will be seen..
< 227 Entering Passive Mode (10,5,80,146,100,199)
* Trying 10.5.80.146... * connected
* Connecting to 10.5.80.146 (10.5.80.146) port 25799
*/
/* After enabling SKIP_PASV_IP flag, the following output will be seen..
< 227 Entering Passive Mode (10,5,80,146,50,229)
* Skips 10.5.80.146 for data connection, uses 10.5.80.146 instead
* Trying 10.5.80.146... * connected
*/
curl_setopt ( $ch , CURLOPT_URL, $url );
curl_setopt ( $ch , CURLOPT_TRANSFERTEXT, 1 );
//force passive connection
curl_setopt ( $ch , CURLOPT_FTP_USE_EPSV, 0 );
curl_setopt ( $ch , CURLOPT_FTP_SKIP_PASV_IP, 1 );
// mark the file for upload..
curl_setopt ( $ch , CURLOPT_INFILE, $fp );
curl_setopt ( $ch , CURLOPT_INFILESIZE, filesize(__FILE__) );
curl_setopt ( $ch , CURLOPT_PUT, 1 );
curl_setopt ( $ch , CURLOPT_UPLOAD, 1 );
$result = curl_exec ( $ch );
var_dump ( $result );
curl_close ( $ch );
?>
===DONE===
@@ -0,0 +1,2 @@
bool(true)
===DONE===
@@ -0,0 +1,6 @@
<?php
$ch = curl_multi_init();
curl_multi_close($ch);
var_dump($ch);
?>
===DONE===
@@ -0,0 +1,2 @@
resource(%d) of type (Unknown)
===DONE===
@@ -0,0 +1,39 @@
<?php
//CURL_MULTI_GETCONTENT TEST
//CREATE RESOURCES
$ch1=curl_init();
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=getpost&get_param=Hello%20World");
curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
//CREATE MULTIPLE CURL HANDLE
$mh=curl_multi_init();
//ADD THE 2 HANDLES
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//EXECUTE
$running=0;
do {
curl_multi_exec($mh,$running);
} while ($running>0);
$results1=curl_multi_getcontent($ch1);
$results2=curl_multi_getcontent($ch2);
//CLOSE
curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
echo $results1;
echo $results2;
?>
@@ -0,0 +1,9 @@
array(2) {
["test"]=>
string(7) "getpost"
["get_param"]=>
string(11) "Hello World"
}
array(0) {
}
CURL2
@@ -0,0 +1,38 @@
<?php
//CURL_MULTI_GETCONTENT TEST
//CREATE RESOURCES
$ch1=curl_init();
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
//CREATE MULTIPLE CURL HANDLE
$mh=curl_multi_init();
//ADD THE 2 HANDLES
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//EXECUTE
$running=0;
do {
curl_multi_exec($mh,$running);
} while ($running>0);
$results1=curl_multi_getcontent(); //no parameter
$results2=curl_multi_getcontent($ch2);
//CLOSE
curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
echo $results1;
echo $results2;
?>
@@ -0,0 +1,2 @@
HipHop Warning: %a
CURL2
@@ -0,0 +1,38 @@
<?php
//CURL_MULTI_GETCONTENT TEST
//CREATE RESOURCES
$ch1=curl_init();
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
//CREATE MULTIPLE CURL HANDLE
$mh=curl_multi_init();
//ADD THE 2 HANDLES
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//EXECUTE
$running=0;
do {
curl_multi_exec($mh,$running);
} while ($running>0);
$results1=curl_multi_getcontent($ch1,$ch2); //no parameter
$results2=curl_multi_getcontent($ch2);
//CLOSE
curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
echo $results1;
echo $results2;
?>
@@ -0,0 +1,2 @@
HipHop Warning: %a
CURL2
@@ -0,0 +1,40 @@
<?php
//CURL_MULTI_GETCONTENT TEST
//CREATE RESOURCES
$ch1=curl_init();
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
//CREATE MULTIPLE CURL HANDLE
$mh=curl_multi_init();
//ADD THE 2 HANDLES
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//EXECUTE
$running=0;
do {
curl_multi_exec($mh,$running);
} while ($running>0);
$ch1="string";
$results1=curl_multi_getcontent($ch1); //incorrect parameter type
$results2=curl_multi_getcontent($ch2);
//CLOSE
//curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
echo $results1;
echo $results2;
?>
@@ -0,0 +1,2 @@
HipHop Warning: %a
CURL2
@@ -0,0 +1,39 @@
<?php
//CURL_MULTI_GETCONTENT TEST
//CREATE RESOURCES
//$ch1=undefined;
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
//CREATE MULTIPLE CURL HANDLE
$mh=curl_multi_init();
//ADD THE 2 HANDLES
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);
//EXECUTE
$running=0;
do {
curl_multi_exec($mh,$running);
} while ($running>0);
$results1=curl_multi_getcontent($ch1); //incorrect parameter type
$results2=curl_multi_getcontent($ch2);
//CLOSE
//curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch2);
curl_multi_close($mh);
echo $results1;
echo $results2;
?>
@@ -0,0 +1,9 @@
HipHop Notice: %a
HipHop Warning: %a
HipHop Notice: %a
HipHop Warning: %a
HipHop Notice: %a
HipHop Warning: %a
HipHop Notice: %a
HipHop Warning: %a
CURL2
@@ -0,0 +1,18 @@
<?php
/* Prototype : resource curl_multi_init(void)
* Description : Returns a new cURL multi handle
* Source code : ext/curl/multi.c
* Test documentation: http://wiki.php.net/qa/temp/ext/curl
*/
// start testing
echo "*** Testing curl_multi_init(void); ***\n";
//create the multiple cURL handle
$mh = curl_multi_init();
var_dump($mh);
curl_multi_close($mh);
var_dump($mh);
?>
===DONE===
@@ -0,0 +1,4 @@
*** Testing curl_multi_init(void); ***
resource(%d) of type (curl_multi)
resource(%d) of type (Unknown)
===DONE===
@@ -0,0 +1,42 @@
<?php
$host = getenv('PHP_CURL_FTP_REMOTE_SERVER');
$username = getenv('PHP_CURL_FTP_REMOTE_USER');
$password = getenv('PHP_CURL_FTP_REMOTE_PASSWD');
// FTP this script to a server
$fp = fopen ( __FILE__ , "r" );
$url = "ftp://$username:$password@$host/" ;
$ch = curl_init ();
curl_setopt ( $ch , CURLOPT_URL, $url );
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER, 1 );
//force passive connection
curl_setopt ( $ch , CURLOPT_FTP_USE_EPSV, 0 );
curl_setopt ( $ch , CURLOPT_FTP_SKIP_PASV_IP, 1 );
$cmh = curl_multi_init();
curl_multi_add_handle($cmh, $ch);
$active = null;
do {
$mrc = curl_multi_exec($cmh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($cmh) != -1) {
do {
$mrc = curl_multi_exec($cmh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
var_dump(is_string(curl_multi_getcontent($ch)));
curl_multi_remove_handle($cmh, $ch);
curl_close($ch);
curl_multi_close($cmh);
?>
===DONE===
@@ -0,0 +1,2 @@
bool(true)
===DONE===
@@ -0,0 +1,39 @@
<?php
function custom_readfunction($oCurl, $hReadHandle, $iMaxOut)
{
$sData = fread($hReadHandle,$iMaxOut-10); # -10 to have space to add "custom:"
if (!empty($sData))
{
$sData = "custom:".$sData;
}
return $sData;
}
$sFileBase = dirname(__FILE__).DIRECTORY_SEPARATOR.'curl_opt_CURLOPT_READFUNCTION';
$sReadFile = $sFileBase.'_in.tmp';
$sWriteFile = $sFileBase.'_out.tmp';
$sWriteUrl = 'file://'.$sWriteFile;
file_put_contents($sReadFile,'contents of tempfile');
$hReadHandle = fopen($sReadFile, 'r');
$oCurl = curl_init();
curl_setopt($oCurl, CURLOPT_URL, $sWriteUrl);
curl_setopt($oCurl, CURLOPT_UPLOAD, 1);
curl_setopt($oCurl, CURLOPT_READFUNCTION, "custom_readfunction" );
curl_setopt($oCurl, CURLOPT_INFILE, $hReadHandle );
curl_exec($oCurl);
curl_close($oCurl);
fclose ($hReadHandle);
$sOutput = file_get_contents($sWriteFile);
var_dump($sOutput);
?>
===DONE===<?php
$sFileBase = dirname(__FILE__).DIRECTORY_SEPARATOR.'curl_opt_CURLOPT_READFUNCTION';
$sReadFile = $sFileBase.'_in.tmp';
$sWriteFile = $sFileBase.'_out.tmp';
unlink($sReadFile);
unlink($sWriteFile);
?>
@@ -0,0 +1,2 @@
string(27) "custom:contents of tempfile"
===DONE===
@@ -0,0 +1,38 @@
<?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');
$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);
var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
@unlink($temp_file);
ob_start(); // start output buffering
$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);
ob_end_clean();
fclose($handle);
unset($handle);
var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
@unlink($temp_file);
curl_close($ch);
?>
@@ -0,0 +1,4 @@
*** Testing curl_setopt with CURLOPT_STDERR
string(%d) "%S"
string(%d) "%S"
* Closing connection #%d
@@ -0,0 +1,29 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** curl_setopt() call with CURLOPT_HTTPHEADER\n";
$url = "{$host}/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, 1);
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
$ch = curl_init();
ob_start(); // start output buffering
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
curl_setopt($ch, CURLOPT_URL, $host);
$curl_content = curl_exec($ch);
ob_end_clean();
curl_close($ch);
var_dump( $curl_content );
?>
@@ -0,0 +1,4 @@
*** curl_setopt() call with CURLOPT_HTTPHEADER
HipHop Warning: %a
bool(false)
bool(true)
@@ -0,0 +1,31 @@
<?php
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
// start testing
echo "*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 1\n";
$url = "{$host}/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$curl_content = curl_exec($ch);
curl_close($ch);
var_dump( $curl_content );
echo "*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 0\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
ob_start();
$curl_content = curl_exec($ch);
ob_end_clean();
curl_close($ch);
var_dump( $curl_content );
?>
@@ -0,0 +1,4 @@
*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 1
string(%d) "%a"
*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 0
bool(true)
@@ -0,0 +1,17 @@
<?php
echo "*** curl_setopt() call with incorrect parameters\n";
$ch = curl_init();
curl_setopt();
curl_setopt(false);
curl_setopt($ch);
curl_setopt($ch, false);
curl_setopt($ch, -1);
curl_setopt($ch, '');
curl_setopt($ch, 1, false);
curl_setopt(false, false, false);
curl_setopt($ch, '', false);
curl_setopt($ch, 1, '');
curl_setopt($ch, -1, 0);
?>
@@ -0,0 +1,10 @@
*** curl_setopt() call with incorrect parameters
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
@@ -0,0 +1,15 @@
<?php
/* Prototype : array curl_version ([ int $age ] )
* Description: Returns information about the cURL version.
* Source code: ext/curl/interface.c
*/
echo "*** Testing curl_version() : error conditions ***\n";
echo "\n-- Testing curl_version() function with more than expected no. of arguments --\n";
$extra_arg = 10;
var_dump( curl_version(1, $extra_arg) );
?>
===Done===
@@ -0,0 +1,6 @@
*** Testing curl_version() : error conditions ***
-- Testing curl_version() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
===Done===

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais