]> granicus.if.org Git - php/commitdiff
improve CURL tests to allow testing without separate server
authorStanislav Malyshev <stas@php.net>
Mon, 12 May 2014 05:21:57 +0000 (22:21 -0700)
committerStanislav Malyshev <stas@php.net>
Mon, 12 May 2014 05:43:08 +0000 (22:43 -0700)
45 files changed:
ext/curl/tests/bug27023.phpt
ext/curl/tests/bug27023_2.phpt [new file with mode: 0644]
ext/curl/tests/bug45161.phpt
ext/curl/tests/bug46711.phpt
ext/curl/tests/bug48203.phpt
ext/curl/tests/bug48203_multi.phpt
ext/curl/tests/bug48207.phpt
ext/curl/tests/bug54798.phpt
ext/curl/tests/bug54995.phpt
ext/curl/tests/bug55767.phpt
ext/curl/tests/bug66109.phpt
ext/curl/tests/curl_CURLOPT_READDATA.phpt
ext/curl/tests/curl_basic_001.phpt
ext/curl/tests/curl_basic_002.phpt
ext/curl/tests/curl_basic_003.phpt
ext/curl/tests/curl_basic_004.phpt
ext/curl/tests/curl_basic_005.phpt
ext/curl/tests/curl_basic_006.phpt
ext/curl/tests/curl_basic_011.phpt
ext/curl/tests/curl_basic_012.phpt
ext/curl/tests/curl_basic_013.phpt
ext/curl/tests/curl_basic_017.phpt
ext/curl/tests/curl_basic_018.phpt
ext/curl/tests/curl_basic_019.phpt
ext/curl/tests/curl_basic_020.phpt
ext/curl/tests/curl_basic_021.phpt
ext/curl/tests/curl_copy_handle_basic_001.phpt
ext/curl/tests/curl_copy_handle_basic_002.phpt
ext/curl/tests/curl_copy_handle_basic_004.phpt
ext/curl/tests/curl_copy_handle_basic_005.phpt
ext/curl/tests/curl_copy_handle_basic_006.phpt
ext/curl/tests/curl_copy_handle_basic_007.phpt
ext/curl/tests/curl_copy_handle_basic_008.phpt
ext/curl/tests/curl_file_deleted_before_curl_close.phpt
ext/curl/tests/curl_file_upload.phpt
ext/curl/tests/curl_multi_getcontent_basic3.phpt
ext/curl/tests/curl_setopt_array_basic.phpt
ext/curl/tests/curl_setopt_basic002.phpt
ext/curl/tests/curl_setopt_basic003.phpt
ext/curl/tests/curl_setopt_basic004.phpt
ext/curl/tests/curl_version_error.phpt
ext/curl/tests/curl_version_variation1.phpt
ext/curl/tests/curl_writeheader_callback.phpt
ext/curl/tests/server.inc [new file with mode: 0644]
ext/curl/tests/skipif.inc [new file with mode: 0644]

index 62effec990be46515374c990f24ac7b9b6b2e01a..fce69f5708bb517da7320fdf61b596a10dac5bff 100644 (file)
@@ -4,18 +4,15 @@ Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files)
 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);
 
diff --git a/ext/curl/tests/bug27023_2.phpt b/ext/curl/tests/bug27023_2.phpt
new file mode 100644 (file)
index 0000000..c878eba
--- /dev/null
@@ -0,0 +1,44 @@
+--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"
index 9fdc7a7e228103f6bae779568f9ca645f619f5b4..bfcd244004cac9814b8270cb487905e876acede3 100644 (file)
@@ -8,9 +8,6 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
 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"); 
index 8eef5562fe71086f1a0c4d71e33a226fdbd040b9..3149c45d7eb378986b9a1300b6c78d7eff83d040 100644 (file)
@@ -5,9 +5,6 @@ Bug #46711 (lost memory when foreach is used for values passed to curl_setopt())
 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
index d8f4d2269fda34da0200c3d851107fd048f14091..aae7fc51a42eda50eec91e98e40812e63f5661c6 100644 (file)
@@ -1,24 +1,17 @@
 --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!
 
index 501b77843e2ef3837628efc81dce248235f07b94..e28c990e93de69792a9e4f5b04c4d25c9448d13e 100644 (file)
@@ -2,16 +2,11 @@
 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');
 
@@ -21,7 +16,7 @@ function checkForClosedFilePointer($curl_option, $description) {
        $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
index 6ac16f5ea831f5617532ca29ebf4e021a1703ff5..a3cd81544b8a1a1093a4a1b281be687f27d2b172 100644 (file)
@@ -4,7 +4,7 @@ Test curl_setopt() CURLOPT_FILE readonly file handle
 Mark van der Velden
 #testfest Utrecht 2009
 --SKIPIF--
-<?php if (!extension_loaded("curl")) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
 --FILE--
 <?php
 /*
@@ -14,7 +14,8 @@ Mark van der Velden
  */
 
 // 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
index afd98cb87e2f1f1b71df5f221fe802a7f954e7a9..4a9b999940de286ca2e0bf18553687a82d967786 100644 (file)
@@ -2,12 +2,7 @@
 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
@@ -47,7 +42,8 @@ $options_to_check = array(
     "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);
 }
index 0f3f50f3444c80f1fbd57f5a1dfb4b5f299d673d..4af59948be968ed8d5cf3e9bbeb60a21ad7f93ab 100644 (file)
@@ -2,20 +2,16 @@
 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);
index 321f67ba602684c5c39cb6bca9784404217e8e45..161ced0bf1ff2e81f99445fff567e1fd333c9c5d 100644 (file)
@@ -2,8 +2,7 @@
 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
@@ -13,7 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index aacfba438a9c91c1e7ce5722887c7bde912e2d5a..5a18e9729457e87f94bb6e0b2932ae46f0c00348 100644 (file)
@@ -1,18 +1,11 @@
 --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);
index ea63d445ac4a6d5a1e5886f8c0207ff00b9f5565..25bd0e9b49f62709a432c93670f99dfea5862b4e 100644 (file)
@@ -4,12 +4,14 @@ Test CURLOPT_READDATA without a callback function
 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');
index fa362b33cec272be63550760688f9f833cd6483c..4921b69bdd45303fbb4befa6c27590372831629b 100644 (file)
@@ -4,10 +4,7 @@ Test curl_exec() function with basic functionality
 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)
@@ -15,8 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index e46f323b5ac44fe43704a8e7b8cce27eadf3e4b7..69aef4b8250beab6a9e9dd874de7968b23515ebd 100644 (file)
@@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_RETURNTRANSFER parameter set to 1
 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)
@@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index eb2aecdd8fffa6b1f8a2383199411cfda04b54f5..9c5967db8fe72910446cdeb36ebbb79cecd00417 100644 (file)
@@ -4,10 +4,7 @@ Test curl_opt() function with POST parameters
 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)
@@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index ea2eeca87caf8d64054d5b35f676c8032fbe30c0..08dc7a100595f58bf926b22e56c12f3d8d3695dd 100644 (file)
@@ -4,10 +4,7 @@ Test curl_opt() function with setting referer
 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)
@@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index 9285c108e27c71d49e1651f32a3ba6ecfbeb176b..200db765dce47ed218f0daac3d4d14b1df3951bd 100644 (file)
@@ -4,10 +4,7 @@ Test curl_opt() function with user agent
 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)
@@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index 5f1a4f48393539985f7b33126c4fd529ae9417d1..66ca036a96e5cf502e96b43fcbdd35204b600e37 100644 (file)
@@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_WRITEFUNCTION parameter set to a closure
 ?
 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)
@@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_R
  * 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";
index 10c90b123a96faf1353d4ce2143af7b76a4c0e25..4e33082409dd25854e70bf6ebd40c8fc93a5007f 100644 (file)
@@ -3,7 +3,7 @@ Test curl_opt() function with COOKIE
 --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)
@@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
  * 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";
index e4706fad46122a8e96eb8bab9d46be84ada11166..f136880dff7acc6687cb1eb36f69efb55ba623af 100644 (file)
@@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_0
 --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)
@@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
  * 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";
index c49d187be31178ffe7388a3edb6a3e04cc41b538..6d09517e8dedeff378f408c33867bf1d1d382434 100644 (file)
@@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_1
 --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)
@@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
  * 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";
index 09247b2c692c29f61f1a136151dbb3554e4c5d85..dc0bee926bba3e1cde022ca9a9eb3881e347c039 100644 (file)
@@ -3,7 +3,7 @@ Test curl_multi_exec() function with basic functionality
 --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)
@@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
  * 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";
index 7cffb89f01749b4065f4aa726651c31e461f9833..359421fc0adcada2f4b08d852323406321016916 100644 (file)
@@ -3,7 +3,7 @@ Test curl_setopt() with curl_multi function with basic functionality
 --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)
@@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com>
  * 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";
index ab605a8c7d549097568e44b3815a6805159fbf50..2c58500ef798cb0ef9b4bbd7b509e888edba5e2c 100644 (file)
@@ -3,22 +3,19 @@ Test curl_getinfo() function with CURLINFO_EFFECTIVE_URL parameter
 --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===
index d6220535060a79c9a8e674170b6628ce06ddcc47..1227ad3261d9f69ad6b69e0981ddc775a22b9cfa 100644 (file)
@@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_HTTP_CODE parameter
 --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();
index 3b4798d51553dc4f2877c54397fae0bbd1f6450c..d9f5a90bef94c9d3b8e6ea6178e22ee5912bb4d6 100644 (file)
@@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_CONTENT_TYPE parameter
 --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();
index f1b4db3ce5f437360baf0498df1ca66038ea7411..aafa41ee2e63eb5e6084840e3b7a6e5ea57d68ef 100644 (file)
@@ -4,11 +4,12 @@ Test curl_copy_handle() with simple get
 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";
 
index 9ab33635fb3ad64973addf8c1c314fd34c49c608..6e8214ad2b151b3c7bbd5874d1217b90318f29b2 100644 (file)
@@ -4,10 +4,11 @@ Test curl_copy_handle() with simple POST
 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";
 
index 9b794e91b47abc49522613ccf1bfa55bc62c061a..c690180a55a9f18c4badf1e94fcc26a0d38d3cb5 100644 (file)
@@ -4,11 +4,12 @@ Test curl_copy_handle() after exec()
 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";
 
index aa9e2fa998c594bccbe86a0de01058472f6ef6ad..e92603324eebf3d0ec3e830fc466e58611c4e3d8 100644 (file)
@@ -4,11 +4,12 @@ Test curl_copy_handle() after exec() with POST
 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";
 
index defc0f232acbcfedf8c481c987b02840b3b0d914..0a5c2a25e6dd9a476a7b4bff84d16fa40c7fafbe 100644 (file)
@@ -4,11 +4,12 @@ Test curl_copy_handle() with User Agent
 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";
 
index aa7306c1c9ed73238b5775edb29b268185c8b9d2..6334d2a4b86900c42c9122ed4213e6081db1720e 100644 (file)
@@ -1,10 +1,11 @@
 --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";
 
index 692c2df192154bfa935934b0b084f13f24622edd..cdb7de374d553444594a821ebb5930fd00784851 100644 (file)
@@ -1,10 +1,11 @@
 --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);
index 3a4d949e7599267c7085b82c043cff22fa965c91..5e806add0812e977384e96ce84dfed4828d161e3 100644 (file)
@@ -3,11 +3,13 @@ Memory corruption error if fp of just created file is closed before curl_close.
 --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)) {
index d3168e578ac981854ddfa84874a1d0b2e1df13f7..b06dedb688a08d9653517dde947ad185124728b2 100644 (file)
@@ -1,14 +1,7 @@
 --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
 
@@ -25,7 +18,8 @@ function testcurl($ch, $name, $mime = '', $postname = '')
        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);
index ac2a3717246d219f35135a104a2cf0d07d0578ae..190fe9d9c03a015c92f8640e9e91dcb4bcd37a4f 100644 (file)
@@ -4,12 +4,7 @@ Curl_multi_getcontent() basic test with different sources (local file/http)
 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
@@ -19,7 +14,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  {
        $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);
index 427de7fc7504715e390fb0e2ff2bb0c90b11f155..d858241b78d9ac4ef4a0f14680c9a639a9712707 100644 (file)
@@ -4,7 +4,7 @@ curl_setopt_array() function - tests setting multiple cURL options with curl_set
 Mattijs Hoitink mattijshoitink@gmail.com
 #Testfest Utrecht 2009
 --SKIPIF--
-<?php if (!extension_loaded("curl")) print "skip"; ?>
+<?php include 'skipif.inc'; ?>
 --FILE--
 <?php
 /*
@@ -15,7 +15,8 @@ Mattijs Hoitink mattijshoitink@gmail.com
  */
 
 // 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";
index 074158a4b39f1ff31ac471e6af28522dd3dace44..7a11493ed20b89404e01357e9398a730a26350ba 100644 (file)
@@ -4,11 +4,12 @@ curl_setopt basic tests with CURLOPT_STDERR.
 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";
index aa225c6e3370a1930a3a34a0bfdb5bd35aa881dd..246b83b4186d331f0b081d680f7eb25dbd4be3cf 100644 (file)
@@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_HTTPHEADER
 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";
index 97b4115e3cf41d5d4b52dad0286a118bde7557e3..ee0b4921d5cdf29f96146be6a0bba17e772b56b2 100644 (file)
@@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_RETURNTRANSFER
 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";
index fb4793af167505f7b1d6c7ea43fff3d0e3ad0b35..a9b80c55be85a320a68976e6ce66fb2881fa293e 100644 (file)
@@ -1,14 +1,7 @@
 --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
index cd912c480333eb9f16bc334b6d6d83d3413a93a8..927b4ac3175f84e9dee794083feaed7464b151f7 100644 (file)
@@ -1,14 +1,7 @@
 --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
index fa27363a4151a16dfde1f26ec1d416c9fa55386f..46e0cc18baa1dd4b587fa69994501e7638a33cf2 100644 (file)
@@ -4,16 +4,9 @@ Test curl option CURLOPT_HEADERFUNCTION
 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
 
@@ -23,7 +16,8 @@ function curl_header_callback($curl_handle, $data)
                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);
diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc
new file mode 100644 (file)
index 0000000..6d96a98
--- /dev/null
@@ -0,0 +1,56 @@
+<?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;
+}
diff --git a/ext/curl/tests/skipif.inc b/ext/curl/tests/skipif.inc
new file mode 100644 (file)
index 0000000..62b252b
--- /dev/null
@@ -0,0 +1,7 @@
+<?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");
+        }
+    }