--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.print_request.php");
+include "helper/server.inc";
+
+echo "Test\n";
function x($a) {
$r[key($a)]=end($a);
$r[key($a)]=reset($a);
return $r;
}
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->setCookies(array("test" => "bar"));
- $client->addCookies(array("foo" => "test"));
- $client->enqueue($request);
- $client->send();
- var_dump($client->getResponse()->getBody()->toString());
- $request->setOptions(array("cookies" => x($client->getCookies())));
- $client->requeue($request);
- $client->send();
- var_dump($client->getResponse()->getBody()->toString());
-}
+server("env.inc", function($port) {
+
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->setCookies(array("test" => "bar"));
+ $client->addCookies(array("foo" => "test"));
+ $client->enqueue($request);
+ $client->send();
+ var_dump($client->getResponse()->getBody()->toString());
+ $request->setOptions(array("cookies" => x($client->getCookies())));
+ $client->requeue($request);
+ $client->send();
+ var_dump($client->getResponse()->getBody()->toString());
+ }
+});
?>
Done
--EXPECTREGEX--
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
+include "helper/server.inc";
+
+echo "Test\n";
$RE =
'/(Array
\(
\(
\[name\] \=\> client010\.php
\[type\] \=\> text\/plain
- \[tmp_name\] \=\> .+
- \[error\] \=\> 0
\[size\] \=\> \d+
\)
\)
)+/';
-$request = new http\Client\Request("POST", "http://dev.iworks.at/ext-http/.print_request.php");
-$request->getBody()->addForm(null, array("file"=>__FILE__, "name"=>"upload", "type"=>"text/plain"));
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- $client->enqueue($request)->send();
- if (!preg_match($RE, $s = $client->getResponse()->getBody()->toString())) {
- echo($s);
+server("env.inc", function($port) use($RE) {
+
+ $request = new http\Client\Request("POST", "http://localhost:$port");
+ $request->getBody()->addForm(null, array("file"=>__FILE__, "name"=>"upload", "type"=>"text/plain"));
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ $client->enqueue($request)->send();
+ if (!preg_match($RE, $s = $client->getResponse()->getBody()->toString())) {
+ echo($s);
+ }
}
-}
+});
?>
Done
--EXPECT--
Test
-Done
\ No newline at end of file
+Done
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
+include "helper/server.inc";
-$body = new http\Message\Body;
-$body->append("foobar");
+echo "Test\n";
-$request = new http\Client\Request;
-$request->setBody($body);
-$request->setRequestMethod("POST");
-$request->setRequestUrl("http://dev.iworks.at/ext-http/.print_request.php");
+server("env.inc", function($port) {
+ $body = new http\Message\Body;
+ $body->append("foobar");
-$client = new http\Client;
-$client->recordHistory = true;
+ $request = new http\Client\Request;
+ $request->setBody($body);
+ $request->setRequestMethod("POST");
+ $request->setRequestUrl("http://localhost:$port");
-$client->enqueue($request)->send();
-echo $client->getHistory()->toString(true);
+ $client = new http\Client;
+ $client->recordHistory = true;
-$client->requeue($request)->send();
-echo $client->getHistory()->toString(true);
+ $client->enqueue($request)->send();
+ echo $client->getHistory()->toString(true);
+ $client->requeue($request)->send();
+ echo $client->getHistory()->toString(true);
+});
?>
Done
--EXPECTF--
Test
-POST http://dev.iworks.at/ext-http/.print_request.php HTTP/1.1
+POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
-Vary: %s
-Content-Type: text/html
-Date: %s
-Server: %s
+Accept-Ranges: bytes
+X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
string(6) "foobar"
-POST http://dev.iworks.at/ext-http/.print_request.php HTTP/1.1
+POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
-Vary: %s
-Content-Type: text/html
-Date: %s
-Server: %s
+Accept-Ranges: bytes
+X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
string(6) "foobar"
-POST http://dev.iworks.at/ext-http/.print_request.php HTTP/1.1
+POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
-Vary: %s
-Content-Type: text/html
-Date: %s
-Server: %s
+Accept-Ranges: bytes
+X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
+include "helper/server.inc";
-$client = new http\Client;
-$client->setOptions(array("compress" => true));
+echo "Test\n";
-$client->enqueue(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.print_request.php"));
-$client->send();
+server("env.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port/");
+
+ $client = new http\Client;
+ $client->setOptions(array("compress" => true));
-echo $client->getResponse();
+ $client->enqueue($request);
+ $client->send();
+ echo $client->getResponse();
+});
?>
===DONE===
--EXPECTF--
Test
HTTP/1.1 200 OK
+Accept-Ranges: bytes
+X-Request-Content-Length: 0
Vary: Accept-Encoding
-Content-Type: text/html
-Date: %s
-Server: %s
+Etag: "%s"
X-Original-Transfer-Encoding: chunked
-X-Original-Content-Encoding: gzip
-===DONE===
\ No newline at end of file
+X-Original-Content-Encoding: deflate
+===DONE===
+
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.cookie1.php");
+include "helper/server.inc";
+
+echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- foreach($client->enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
- var_dump($cookies->toArray());
+server("cookie1.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ foreach($client->enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
+ var_dump($cookies->toArray());
+ }
}
-}
+});
?>
Done
--EXPECTREGEX--
--SKIPIF--
<?php
include "skipif.inc";
-skip_online_test();
skip_client_test();
?>
--FILE--
<?php
-echo "Test\n";
-$request = new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.cookie.php");
+include "helper/server.inc";
+
+echo "Test\n";
-foreach (http\Client::getAvailableDrivers() as $driver) {
- $client = new http\Client($driver);
- foreach($client->enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
- var_dump($cookies->toArray());
+server("cookie2.inc", function($port) {
+ $request = new http\Client\Request("GET", "http://localhost:$port");
+
+ foreach (http\Client::getAvailableDrivers() as $driver) {
+ $client = new http\Client($driver);
+ foreach($client->enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
+ var_dump($cookies->toArray());
+ }
}
-}
+});
?>
Done
--EXPECTREGEX--
--- /dev/null
+<?php
+
+include "server.inc";
+
+serve(function($client) {
+ $request = new http\Message($client, false);
+ $cookies = new http\Cookie();
+ $cookies->setCookie("foo", "bar");
+ $cookies->setCookie("bar", "foo");
+ $response = new http\Env\Response;
+ $response->setCookie($cookies);
+ $response->send($client);
+});
--- /dev/null
+<?php
+
+include "server.inc";
+
+serve(function($client) {
+ $request = new http\Message($client, false);
+ $response = new http\Env\Response;
+ $old_cookies = new http\Cookie($request->getHeader("Cookie"));
+ $new_cookies = new http\Cookie;
+ $new_cookies->setCookie("temp", $old_cookies->getCookie("temp") ?: microtime(true));
+ $response->setCookie($new_cookies);
+ $new_cookies = new http\Cookie;
+ $new_cookies->setCookie("perm", $old_cookies->getCookie("perm") ?: microtime(true));
+ $new_cookies->setExpires(time()+3600);
+ $response->setCookie($new_cookies);
+ $response->send($client);
+});
--- /dev/null
+<?php
+
+include "dump.inc";
+include "server.inc";
+
+serve(function($client) {
+ $request = new http\Message($client, false);
+ $response = new http\Env\Response;
+ $response->setEnvRequest($request);
+ $response->setContentEncoding(http\Env\Response::CONTENT_ENCODING_GZIP);
+ $response->setHeader("X-Request-Content-Length", $request->getBody()->stat("size"));
+ ob_start($response);
+ if ($request->isMultipart()) {
+ $files = [];
+ foreach ($request->splitMultipartBody() as $part) {
+ $cd = $part->getHeader("Content-Disposition", http\Header::class)->getParams();
+ foreach ($cd->params as $key => $val) {
+ if ($key === "form-data" && $val["value"] === true) {
+ if (isset($val["arguments"]["filename"])) {
+ $files[$val["arguments"]["name"]] = [
+ "name" => $val["arguments"]["filename"],
+ "type" => $part->getHeader("Content-Type"),
+ "size" => $part->getBody()->stat("s"),
+ ];
+ }
+ }
+ }
+ print_r($files);
+ }
+ } else {
+ if (($c = $request->getHeader("Cookie"))) {
+ print_r((new http\Cookie($c))->getCookies());
+ }
+ if ($request->getBody()->stat("s")) {
+ var_dump($request->getBody()->toString());
+ }
+ }
+ ob_end_flush();
+ $response->send($client);
+});