error_reporting = E_ALL & ~E_DEPRECATED
--SKIPIF--
<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
+include 'skipif.inc';
?>
--FILE--
<?php
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
$ch = curl_init();
+curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0);
curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
--- /dev/null
+--TEST--
+Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files)
+--INI--
+error_reporting = E_ALL & ~E_DEPRECATED
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'server.inc';
+$host = curl_cli_server_start();
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1);
+curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+$file = curl_file_create(__DIR__ . '/curl_testdata1.txt');
+$params = array('file' => $file);
+curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
+var_dump(curl_exec($ch));
+
+$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain");
+$params = array('file' => $file);
+curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
+var_dump(curl_exec($ch));
+
+$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', null, "foo.txt");
+$params = array('file' => $file);
+curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
+var_dump(curl_exec($ch));
+
+$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain", "foo.txt");
+$params = array('file' => $file);
+curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
+var_dump(curl_exec($ch));
+
+
+curl_close($ch);
+?>
+--EXPECTF--
+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"
if (!extension_loaded("curl")) {
exit("skip curl extension not loaded");
}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x071100) {
exit("skip: test works only with curl >= 7.17.0");
if (!extension_loaded("curl")) {
exit("skip curl extension not loaded");
}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
?>
--FILE--
<?php
--TEST--
Bug #48203 (Crash when CURLOPT_STDERR is set to regular file)
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-
+include 'server.inc';
$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'));
+curl_setopt($ch, CURLOPT_URL, curl_cli_server_start());
fclose($fp); // <-- premature close of $fp caused a crash!
Variation of bug #48203 with curl_multi_exec (Crash when file pointers passed to curl are closed before calling curl_multi_exec)
--SKIPIF--
<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
+include 'skipif.inc';
?>
--FILE--
<?php
-
+include 'server.inc';
function checkForClosedFilePointer($curl_option, $description) {
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$options = array(
CURLOPT_RETURNTRANSFER => 1,
$curl_option => $fp,
- CURLOPT_URL => getenv("PHP_CURL_HTTP_REMOTE_SERVER")
+ CURLOPT_URL => curl_cli_server_start()
);
// we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly
Mark van der Velden
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl")) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/*
*/
// Figure out what handler to use
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
if(!empty($host)) {
// Use the set Environment variable
Bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec)
--SKIPIF--
<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
+include 'skipif.inc';
?>
--FILE--
<?php
"CURLOPT_INFILE"
);
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
foreach($options_to_check as $option) {
checkForClosedFilePointer($host, constant($option), $option);
}
Bug #54995 (Missing CURLINFO_RESPONSE_CODE support)
--SKIPIF--
<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
+include 'skipif.inc';
+
if ($curl_version['version_number'] > 0x070a08) {
exit("skip: tests works a versions of curl >= 7.10.8");
}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
?>
--FILE--
<?php
-
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Test curl_opt() function with POST params from array with a numeric key
--SKIPIF--
<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+include 'skipinf.inc';
?>
--FILE--
<?php
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl sending through GET an POST ***' . "\n";
--TEST--
Bug #66109 (Option CURLOPT_CUSTOMREQUEST can't be reset to default.)
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=method");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Mattijs Hoitink mattijshoitink@gmail.com
#Testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
+include 'server.inc';
+$host = curl_cli_server_start();
// The URL to POST to
-$url = getenv('PHP_CURL_HTTP_REMOTE_SERVER') . '/get.php?test=post';
+$url = $host . '/get.php?test=post';
// Create a temporary file to read the data from
$tempname = tempnam(sys_get_temp_dir(), 'CURL_DATA');
Sebastian Deutsch <sebastian.deutsch@9elements.com>
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_exec(resource ch)
* Source code: ext/curl/interface.c
* Alias to functions:
*/
-
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
Sebastian Deutsch <sebastian.deutsch@9elements.com>
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n";
Sebastian Deutsch <sebastian.deutsch@9elements.com>
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl sending through GET an POST ***' . "\n";
Sebastian Deutsch <sebastian.deutsch@9elements.com>
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl setting referer ***' . "\n";
Sebastian Deutsch <sebastian.deutsch@9elements.com>
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl with user agent ***' . "\n";
?
TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); ***' . "\n";
--CREDITS--
TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl with cookie ***' . "\n";
--CREDITS--
TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl with HTTP/1.0 ***' . "\n";
--CREDITS--
TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo '*** Testing curl with HTTP/1.1 ***' . "\n";
--CREDITS--
TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_multi_exec(resource ch)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
--CREDITS--
TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/* Prototype : bool curl_setopt(resource ch, int option, mixed value)
* Alias to functions:
*/
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
// start testing
echo "*** Testing curl_exec() : basic functionality ***\n";
--CREDITS--
Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
- $url = "{$host}/get.php?test=";
+ $url = "http://{$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===
--CREDITS--
Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
$url = "{$host}/get.php?test=";
$ch = curl_init();
--CREDITS--
Jean-Marc Fontaine <jmf@durcommefaire.net>
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) exit("skip curl extension not loaded");
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
$url = "{$host}/get.php?test=contenttype";
$ch = curl_init();
Rick Buitenman <rick@meritos.nl>
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Testing curl copy handle with simple GET ***' . "\n";
Rick Buitenman <rick@meritos.nl>
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Testing curl copy handle with simple POST ***' . "\n";
Rick Buitenman <rick@meritos.nl>
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Test curl_copy_handle() after exec() ***' . "\n";
Rick Buitenman <rick@meritos.nl>
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Test curl_copy_handle() after exec() with POST ***' . "\n";
Rick Buitenman <rick@meritos.nl>
#testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Testing curl copy handle with User Agent ***' . "\n";
--TEST--
Test curl_copy_handle() with simple POST
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
echo '*** Testing curl copy handle with simple POST using array as arguments ***' . "\n";
--TEST--
Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
$url = "{$host}/get.php";
$ch = curl_init($url);
--CREDITS--
Alexey Shein <confik@gmail.com>
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-$ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER'));
+include 'server.inc';
+$host = curl_cli_server_start();
+$ch = curl_init($host);
$temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp';
if (file_exists($temp_file)) {
--TEST--
CURL file uploading
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- exit("skip curl extension not loaded");
-}
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
var_dump(curl_exec($ch));
}
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Rein Velt (rein@velt.org)
#TestFest Utrecht 20090509
--SKIPIF--
-<?php
-if (!extension_loaded('curl')) print 'skip need ext/curl';
-if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
-}
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
//CURL_MULTI_GETCONTENT TEST
$ch2=curl_init();
//SET URL AND OTHER OPTIONS
- $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ include 'server.inc';
+ $host = curl_cli_server_start();
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);
Mattijs Hoitink mattijshoitink@gmail.com
#Testfest Utrecht 2009
--SKIPIF--
-<?php if (!extension_loaded("curl")) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
/*
*/
// Figure out what handler to use
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
if (!empty($host)) {
// Use the set Environment variable
$url = "{$host}/get.php?test=get";
Paul Sohier
#phptestfest utrecht
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
// start testing
echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
Paul Sohier
#phptestfest utrecht
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
// start testing
echo "*** curl_setopt() call with CURLOPT_HTTPHEADER\n";
Paul Sohier
#phptestfest utrecht
--SKIPIF--
-<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
// start testing
echo "*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 1\n";
--TEST--\r
Test curl_version() function : error conditions\r
--SKIPIF--\r
-<?php \r
-if (!extension_loaded("curl")) {\r
- die('skip - curl extension not available in this build'); \r
-}\r
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {\r
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";\r
-}\r
-?>\r
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>\r
--FILE--\r
<?php\r
\r
--TEST--\r
Test curl_version() function : usage variations - test values for $ascii argument\r
--SKIPIF--\r
-<?php \r
-if (!extension_loaded("curl")) {\r
- echo "skip - curl extension not available in this build";\r
-}\r
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {\r
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";\r
-}\r
-?>\r
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>\r
--FILE--\r
<?php\r
\r
Mathieu Kooiman <mathieuk@gmail.com>
Dutch UG, TestFest 2009, Utrecht
--DESCRIPTION--
-Hit the host identified by PHP_CURL_HTTP_REMOTE_SERVER and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers specified for PHP_CURL_HTTP_REMOTE_SERVER might return different sets of headers. Just test for HTTP/1.1 200 OK.
+Hit the host and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers might return different sets of headers. Just test for HTTP/1.1 200 OK.
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- echo "skip - curl extension not available in this build";
-}
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
-}
-?>
+<?php include 'skipif.inc'; ?>
--FILE--
<?php
echo $data;
}
-$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+include 'server.inc';
+$host = curl_cli_server_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
--- /dev/null
+<?php
+
+define ("PHP_CURL_SERVER_HOSTNAME", "localhost");
+define ("PHP_CURL_SERVER_PORT", 8964);
+define ("PHP_CURL_SERVER_ADDRESS", PHP_CURL_SERVER_HOSTNAME.":".PHP_CURL_SERVER_PORT);
+
+function curl_cli_server_start() {
+ if(getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ return getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+ }
+
+ $php_executable = getenv('TEST_PHP_EXECUTABLE');
+ $doc_root = __DIR__;
+ $router = "responder/get.php";
+
+ $descriptorspec = array(
+ 0 => STDIN,
+ 1 => STDOUT,
+ 2 => STDERR,
+ );
+
+ if (substr(PHP_OS, 0, 3) == 'WIN') {
+ $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS;
+ $cmd .= " {$router}";
+ $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
+ } else {
+ $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS;
+ $cmd .= " {$router}";
+ $cmd .= " 2>/dev/null";
+
+ $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
+ }
+
+ // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
+ // it might not be listening yet...need to wait until fsockopen() call returns
+ $i = 0;
+ while (($i++ < 30) && !($fp = @fsockopen(PHP_CURL_SERVER_HOSTNAME, PHP_CURL_SERVER_PORT))) {
+ usleep(10000);
+ }
+
+ if ($fp) {
+ fclose($fp);
+ }
+
+ register_shutdown_function(
+ function($handle) use($router) {
+ proc_terminate($handle);
+ },
+ $handle
+ );
+ // don't bother sleeping, server is already up
+ // server can take a variable amount of time to be up, so just sleeping a guessed amount of time
+ // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass
+ // sleeping doesn't work.
+ return PHP_CURL_SERVER_ADDRESS;
+}
--- /dev/null
+<?php
+ if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+ if(false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ if (php_sapi_name() != "cli") {
+ die("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+ }
+ }