--SKIPIF--
<?php
include "skipif.inc";
+skip_client_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
+
+include "server.inc";
+
echo "Test\n";
class Observer implements SplObserver
}
}
-$observer = new Observer;
-$request = new http\Client\Request("GET", "http://www.example.org/");
-
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->attach($observer);
- $client->enqueue($request);
- $client->send();
-}
+server("proxy.inc", function($port, $stdin, $stdout, $stderr) {
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->attach(new Observer);
+ $client->enqueue(new http\Client\Request("GET", "http://localhost:$port/"));
+ $client->send();
+ }
+});
?>
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://www.example.org/");
+include "server.inc";
+
+echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->enqueue($request);
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://www.example.org/");
- while ($client->once()) {
- $client->wait(.1);
- }
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->enqueue($request);
+
+ while ($client->once()) {
+ $client->wait(.1);
+ }
- if (!$client->getResponse()) {
- var_dump($client);
+ if (!$client->getResponse()) {
+ var_dump($client);
+ }
}
-}
+});
?>
Done
--EXPECT--
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://www.example.org");
+include "server.inc";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->enqueue($request)->send();
- if (!($client->getResponse($request) instanceof http\Client\Response)) {
- var_dump($client);
- }
- try {
+echo "Test\n";
+
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->enqueue($request)->send();
+ if (!($client->getResponse($request) instanceof http\Client\Response)) {
+ var_dump($client);
+ }
+ try {
+ $client->enqueue($request);
+ } catch (Exception $e) {
+ echo $e->getMessage(),"\n";
+ }
+ $client->reset();
+ if (($response = $client->getResponse())) {
+ var_dump($response);
+ }
$client->enqueue($request);
- } catch (Exception $e) {
- echo $e->getMessage(),"\n";
- }
- $client->reset();
- if (($response = $client->getResponse())) {
- var_dump($response);
}
- $client->enqueue($request);
-}
+ });
?>
Done
--EXPECTREGEX--
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
+
+include "server.inc";
+
echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->enqueue(new http\Client\Request("GET", "http://www.example.org"), function($response) {
- echo "R\n";
- if (!($response instanceof http\Client\Response)) {
- var_dump($response);
- }
- });
- $client->send();
-}
+server("proxy.inc", function($port) {
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->enqueue(new http\Client\Request("GET", "http://localhost:$port"), function($response) {
+ echo "R\n";
+ if (!($response instanceof http\Client\Response)) {
+ var_dump($response);
+ }
+ });
+ $client->send();
+ }
+});
?>
Done
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
+
+include "server.inc";
+
echo "Test\n";
function response($response) {
return true;
}
-$request = new http\Client\Request("GET", "http://www.example.org");
-
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- for ($i=0; $i < 2; ++ $i) {
- $client->enqueue($request, "response");
- $client->send();
- try {
- $client->dequeue($request);
- } catch (Exception $e) {
- echo $e->getMessage(),"\n";
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ for ($i=0; $i < 2; ++ $i) {
+ $client->enqueue($request, "response");
+ $client->send();
+ try {
+ $client->dequeue($request);
+ } catch (Exception $e) {
+ echo $e->getMessage(),"\n";
+ }
}
}
-}
+});
?>
Done
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
+
+include "server.inc";
+
echo "Test\n";
function response($response) {
}
}
-$request = new http\Client\Request("GET", "http://www.example.org");
-
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- for ($i=0; $i < 2; ++ $i) {
- $client->requeue($request, "response");
- $client->send();
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ for ($i=0; $i < 2; ++ $i) {
+ $client->requeue($request, "response");
+ $client->send();
+ }
}
-}
+});
?>
Done
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://www.example.org");
+include "server.inc";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->configure(["pipelining" => true, "use_eventloop" => true]);
+echo "Test\n";
+
+server("pipeline.inc", function($port, $stdin) {
+ fputs($stdin, "2\n");
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ $client = new http\Client();
+ $client->configure(["pipelining" => true, "use_eventloop" => true]);
+
$client->enqueue($request);
+ $client->send();
+
$client->enqueue(clone $request);
$client->enqueue(clone $request);
-
+
$client->send();
-
+
while ($client->getResponse()) {
echo "R\n";
}
-}
+});
?>
Done
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-
echo "Test\n";
$client = new http\Client;
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
+include "server.inc";
+
echo "Test\n";
class Client extends http\Client {
}
}
-$client = new Client;
-$client->attach($o1 = new ProgressObserver1);
-$client->attach($o2 = new ProgressObserver2);
-$client->attach(
- $o3 = new CallbackObserver(
- function ($c, $r) {
- $p = (array) $c->getProgressInfo($r);
- var_dump(array_key_exists("started", $p));
- var_dump(array_key_exists("finished", $p));
- var_dump(array_key_exists("dlnow", $p));
- var_dump(array_key_exists("ulnow", $p));
- var_dump(array_key_exists("dltotal", $p));
- var_dump(array_key_exists("ultotal", $p));
- var_dump(array_key_exists("info", $p));
- }
- )
-);
-
-$client->enqueue(new http\Client\Request("GET", "http://www.example.com/"))->send();
-var_dump(1 === preg_match("/(\.-)+/", $client->pi));
-var_dump(3 === count($client->getObservers()));
-$client->detach($o1);
-var_dump(2 === count($client->getObservers()));
-$client->detach($o2);
-var_dump(1 === count($client->getObservers()));
-$client->detach($o3);
-var_dump(0 === count($client->getObservers()));
+server("proxy.inc", function($port) {
+ $client = new Client;
+ $client->attach($o1 = new ProgressObserver1);
+ $client->attach($o2 = new ProgressObserver2);
+ $client->attach(
+ $o3 = new CallbackObserver(
+ function ($c, $r) {
+ $p = (array) $c->getProgressInfo($r);
+ var_dump(array_key_exists("started", $p));
+ var_dump(array_key_exists("finished", $p));
+ var_dump(array_key_exists("dlnow", $p));
+ var_dump(array_key_exists("ulnow", $p));
+ var_dump(array_key_exists("dltotal", $p));
+ var_dump(array_key_exists("ultotal", $p));
+ var_dump(array_key_exists("info", $p));
+ }
+ )
+ );
+
+ $client->enqueue(new http\Client\Request("GET", "http://localhost:$port/"))->send();
+ var_dump(1 === preg_match("/(\.-)+/", $client->pi));
+ var_dump(3 === count($client->getObservers()));
+ $client->detach($o1);
+ var_dump(2 === count($client->getObservers()));
+ $client->detach($o2);
+ var_dump(1 === count($client->getObservers()));
+ $client->detach($o3);
+ var_dump(0 === count($client->getObservers()));
+
+});
?>
Done
--SKIPIF--
<?php
include "skipif.inc";
+skip_client_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-
-$client1 = new http\Client;
-$client2 = new http\Client;
-
-$client1->configure(["use_eventloop" => true]);
-$client2->configure(["use_eventloop" => true]);
-$client1->enqueue(new http\Client\Request("GET", "http://www.google.ca/"));
-$client2->enqueue(new http\Client\Request("GET", "http://www.google.co.uk/"));
+include "server.inc";
-$client1->send();
-
-if (($r = $client1->getResponse())) {
- var_dump($r->getTransferInfo("response_code"));
-}
-if (($r = $client2->getResponse())) {
- var_dump($r->getTransferInfo("response_code"));
-}
+echo "Test\n";
+server("proxy.inc", function($port) {
+ $client1 = new http\Client;
+ $client2 = new http\Client;
+
+ $client1->configure(["use_eventloop" => true]);
+ $client2->configure(["use_eventloop" => true]);
+
+ $client1->enqueue(new http\Client\Request("GET", "http://localhost:$port/"));
+ $client2->enqueue(new http\Client\Request("GET", "http://localhost:$port/"));
+
+ $client1->send();
+
+ if (($r = $client1->getResponse())) {
+ var_dump($r->getTransferInfo("response_code"));
+ }
+ if (($r = $client2->getResponse())) {
+ var_dump($r->getTransferInfo("response_code"));
+ }
+
+});
?>
DONE
--EXPECT--
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://www.example.org/");
+include "server.inc";
+
+echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->configure(["use_eventloop" => true]);
- $client->enqueue($request);
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port/");
- while ($client->once()) {
- $client->wait(.1);
- }
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->configure(["use_eventloop" => true]);
+ $client->enqueue($request);
+
+ while ($client->once()) {
+ $client->wait(.1);
+ }
- if (!$client->getResponse()) {
- var_dump($client);
+ if (!$client->getResponse()) {
+ var_dump($client);
+ }
}
-}
+});
?>
Done
--EXPECT--
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
<?php
include "skipif.inc";
skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
+skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://www.example.org");
+include "server.inc";
+
+echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $response = $client->enqueue($request)->send()->getResponse();
- var_dump($response->getTransferInfo("response_code"));
- var_dump(count((array)$response->getTransferInfo()));
-}
+server("proxy.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $response = $client->enqueue($request)->send()->getResponse();
+ var_dump($response->getTransferInfo("response_code"));
+ var_dump(count((array)$response->getTransferInfo()));
+ }
+});
?>
Done
--EXPECTREGEX--
--FILE--
<?php
+include "server.inc";
+
echo "Test\n";
-$spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
-if (($proc = proc_open(PHP_BINARY . " proxy.inc", $spec, $pipes, __DIR__))) {
- $port = trim(fgets($pipes[2]));
+server("proxy.inc", function($port, $stdin, $stdout, $stderr) {
echo "Server on port $port\n";
$c = new http\Client;
$r = new http\Client\Request("GET", "http://localhost:$port/");
echo $e;
}
echo $c->getResponse()->getBody();
- while (!feof($pipes[1])) {
- echo fgets($pipes[1]);
- }
unset($r, $client);
-}
+});
+
?>
===DONE===
--EXPECTF--
foreach (range(8000, 9000) as $port) {
if (($server = stream_socket_server("tcp://localhost:$port"))) {
fprintf(STDERR, "%s\n", $port);
- if (($client = stream_socket_accept($server))) {
- $cb($client);
- }
+ do {
+ $R = [$server]; $W = []; $E = [];
+ $select = stream_select($R, $E, $E, 0, 10000);
+ if ($select && ($client = stream_socket_accept($server, 1))) {
+ if (getenv("PHP_HTTP_TEST_SSL")) {
+ stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER);
+ }
+ while (!feof($client)) {
+ $cb($client);
+ }
+ }
+ } while ($select !== false);
return;
}
}
if (($proc = proc_open(PHP_BINARY . " $file", $spec, $pipes, __DIR__))) {
$port = trim(fgets($pipes[2]));
- $cb($port,
- $stdin = $pipes[0],
- $stdout = $pipes[1],
- $stderr = $pipes[2]);
+ $cb($port, $stdin = $pipes[0], $stdout = $pipes[1], $stderr = $pipes[2]);
+
+ proc_terminate($proc);
fpassthru($stderr);
fpassthru($stdout);