ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
PK R]eҪ tests/helper/server.incnu [ getMessage());
/* ignore disconnect */
if ($ex->getMessage() !== "Empty message received from stream") {
fprintf(STDERR, "%s\n", $ex);
}
break;
}
}
} while ($select);
return;
}
}
}
function server($handler, $cb) {
$args = [];
$argList = preg_split('#\s+#', getenv('TEST_PHP_ARGS'), -1, PREG_SPLIT_NO_EMPTY);
for ($i = 0; isset($argList[$i]); $i++) {
if ($argList[$i] === '-c') {
array_push($args, '-c', $argList[++$i]);
continue;
}
if ($argList[$i] === '-n') {
$args[] = '-n';
continue;
}
if ($argList[$i] === '-d') {
$args[] = '-d' . $argList[++$i];
continue;
}
if (substr($argList[$i], 0, 2) === '-d') {
$args[] = $argList[$i];
}
}
foreach (['raphf', 'http'] as $ext) {
if (null !== $arg = get_extension_load_arg(PHP_BIN, $args, $ext)) {
$args[] = $arg;
}
}
$args[] = __DIR__ . '/' . $handler;
proc(PHP_BIN, $args, $cb);
}
function nghttpd($cb) {
$spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
$offset = rand(0,2000);
foreach (range(8000+$offset, 9000+$offset) as $port) {
$comm = "exec nghttpd -d html $port http2.key http2.crt";
if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) {
$stdin = $pipes[0];
$stdout = $pipes[1];
$stderr = $pipes[2];
sleep(1);
$status = proc_get_status($proc);
logger("nghttpd: %s", new http\Params($status));
if (!$status["running"]) {
continue;
}
try {
$cb($port, $stdin, $stdout, $stderr);
} catch (Exception $e) {
echo $e,"\n";
}
proc_terminate($proc);
fpassthru($stderr);
fpassthru($stdout);
return;
}
}
}
function proc($bin, $args, $cb) {
$spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
$comm = escapeshellcmd($bin) . " ". implode(" ", array_map("escapeshellarg", $args));
logger("proc: %s %s", $bin, implode(" ", $args));
if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) {
$stdin = $pipes[0];
$stdout = $pipes[1];
$stderr = $pipes[2];
do {
$port = trim(fgets($stderr));
$R = array($stderr); $W = array(); $E = array();
} while (is_numeric($port) && stream_select($R, $W, $E, 0, 10000));
if (is_numeric($port)) {
try {
$cb($port, $stdin, $stdout, $stderr);
} catch (Exception $e) {
echo $e,"\n";
}
}
proc_terminate($proc);
fpassthru($stderr);
fpassthru($stdout);
}
}
PK R] tests/helper/html/index.htmlnu [
HTTP2
Nothing to see here.
PK R]}@? ? tests/helper/cookie.incnu [ getHeader("cookie"));
$response = new http\Env\Response;
$response->setCookie($cookies->setCookie("counter", $cookies->getCookie("counter")+1));
$response->send($client);
});
PK R]77 7 tests/helper/upload.incnu [ getHeader("Expect") === "100-continue") {
$response = new http\Env\Response;
$response->setEnvRequest($request);
$response->setResponseCode(100);
$response->send($client);
}
/* return the initial message as response body */
$response = new http\Env\Response;
/* avoid OOM with $response->getBody()->append($request); */
dump_message($response->getBody()->getResource(), $request);
$response->send($client);
});
PK R]i^ ^ tests/helper/proxy.incnu [ = 7.48 does not send Proxy-Connection anymore */
if ($request->getHeader("Proxy-Connection")
|| $request->getRequestMethod() === "CONNECT") {
$response = new http\Env\Response;
$response->setEnvRequest($request);
$response->send($client);
/* soak up the request following the connect */
new http\Message($client, false);
}
/* return the initial message as response body */
$response = new http\Env\Response;
$response->setHeader("X-Request-Content-Length", $request->getBody()->stat("size"));
/* avoid OOM with $response->getBody()->append($request); */
dump_message($response->getBody()->getResource(), $request);
$response->send($client);
});
PK R]/E{J J tests/helper/cookie2.incnu [ 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);
});
PK R]F tests/helper/pipeline.incnu [ setEnvRequest($msg)
->setHeader("X-Req", $msg->getRequestUrl())
->send($client);
}
serve(function($client) {
$R = array(STDIN); $W = $E = array();
if (!stream_select($R, $W, $E, 10, 0)) {
logger("Client %d timed out", (int) $client);
return;
}
$count = trim(fgets(STDIN));
logger("Expecting %d messages from client %d", $count, (int) $client);
/* the peek message */
respond($client, new http\Message($client, false));
logger("Handled the peek request of client %d", (int) $client);
/* pipelined messages */
$req = array();
for ($i=0; $i < $count; ++ $i) {
$req[] = $m = new http\Message($client, false);
logger("Read request no. %d from client %d (%s)", $i+1, (int) $client, $m->getRequestUrl());
}
foreach ($req as $i => $msg) {
respond($client, $msg);
logger("Sent response no. %d to client %d", $i+1, (int) $client);
}
});
PK R]G'ֱ tests/helper/env.incnu [ 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);
});
PK R]ٞΏ tests/helper/http2.keynu [ -----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAzFr4DrEQpA5iZ7nmdDK7Sqm+8YHhzjAYE1rpfpgATMQdzX01
uLHTZRlZCAczV2YGFtUNbey07jYJCZxWIgp8DLlHUD1RmNRyf2dClrEv+yn0uusI
A3KWMhJdLjRBwG+ELOZxS8NYFGFVMaNX5BNpiaZoz7yEkkkzpbsHIg/bZm+MegCf
NPH2yOz44zJaaNhP2la/poT67mJILxufcHQaC18/Cg+oMXx4/EgwGma1uTsmpcXM
fFNXLCTKmewXfhcr3hCOm9FwUZKD8NzVOikkbZZ+ryHHC2gp6tKUvm3IrLRmuW3E
KIuR9VmLHA1kSqSDuM9JS8tLb32YGvDL6KSavwIDAQABAoIBAQCzUdAB9FYJ36Vy
J6qVpD69EZ7ABZzDdWhq84eY0oDQ2/ba7lhJraE2QbviU481zgzh1CponyFVNo1P
paPfUxvvflWZj3Ueiq2+JjpESU81MmfR7ZOmktJBNeQWOzzHRBPT4pLgTJXprE85
s3/YX0BozWGDiIU8aIetkiR8OzXm97+BrJWiPFl733dGnHvfpHAZu/PwKZc2+8ft
CnQw4GHRhTBWCVNj29HLwm+CA66zQqiAXItgijWMKzs+9ciPn+aCsCnZDNF+o1zs
4pWt60CtIJQtD3r3rSRy7nBaCKcTrr/JU3FvwqKdunuUBUsuYeSaMBokW67kpVzS
dO9L9p6BAoGBAP+pvcAd8qfC1WIrn9vka3aK25ulbYSCae3YaWmABc93INJPBMvO
GrcUuaLKiQC1oou+E64vGyJ9MeEFwxh2zbvU75a9ezeKAajgaq92ciMX2QqREh0N
IntNOc4w7eB6BK8NpaDXNvTtxNWMvlYyhVN0M7FVQRmYJfCJdnTZAkzvAoGBAMyf
6rvWuc/wmIcAtBVe+jIeQ69EJJ/Idcjk0JUm6lFECAAraPpsCglha+wTHWWRQZ9u
pPqBnb7QPjevU+3bZHnMvGoEzd5F4Rw74J+p5EZeMUJpuKmon7Ekzemcb0DV+qX9
NorB781D2Z0MG9SCptKyKpN5TPHTjGz4BB3mLC8xAoGAdq99/ynn9ClmleRameI4
YRelS2RIqzM/qcLFbMyZ5e4PtpIoT9SmYkekxgXwA/xOMUFUMZB8sE4eUbAzGbBN
Yd1APGJKSUYv7w3/eOUrp07y2wzts77dOxBmvWnJhGQguINFWJ2QTbPzpI9p7OoX
Kt7PAIvrZM5VDo1CCIyVnNECgYEAgLmpZXlzcwicK3GZ2EfjhVvcoIlxsMLetf6b
6PiON4lgrxqf88m7lqMezWhI+fgjHDTyvFSF89/1A/rcBaoazzSo4tka2VWEg8p3
SHoMDOh8fJcdgD2AGGRa1TeAFX2HLJzajvfp72tbnpxbdZircah7eEK60PaQRIzR
qi1+ZkECgYEAi7GkO7Ey98DppLnt7567veQoEj0u8ixTlCyJ4V278nHR5+6eAZP5
PfdZVC3MtKGLnxrrPTVUy5wU0hR6Gk9EVDmrAF8TgJdnZFlBK7X23eWZ0q4qO/eO
3xIi+UrNwLag8BjYOr32nP/i+F+TLikgRIFR4oiZjk867+ofkTXmNFA=
-----END RSA PRIVATE KEY-----
PK R]ϥ2 2 tests/helper/cookie1.incnu [ setCookie("foo", "bar");
$cookies->setCookie("bar", "foo");
$response = new http\Env\Response;
$response->setCookie($cookies);
$response->send($client);
});
PK R]h tests/helper/http2.crtnu [ -----BEGIN CERTIFICATE-----
MIIDNzCCAh+gAwIBAgIJAKOw1awbt7aIMA0GCSqGSIb3DQEBCwUAMDIxCzAJBgNV
BAYTAkFUMQ8wDQYDVQQKDAZQSFAgUUExEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0x
NTAyMTIxMjQ2NTRaFw0xNzExMDcxMjQ2NTRaMDIxCzAJBgNVBAYTAkFUMQ8wDQYD
VQQKDAZQSFAgUUExEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEB
BQADggEPADCCAQoCggEBAMxa+A6xEKQOYme55nQyu0qpvvGB4c4wGBNa6X6YAEzE
Hc19Nbix02UZWQgHM1dmBhbVDW3stO42CQmcViIKfAy5R1A9UZjUcn9nQpaxL/sp
9LrrCANyljISXS40QcBvhCzmcUvDWBRhVTGjV+QTaYmmaM+8hJJJM6W7ByIP22Zv
jHoAnzTx9sjs+OMyWmjYT9pWv6aE+u5iSC8bn3B0GgtfPwoPqDF8ePxIMBpmtbk7
JqXFzHxTVywkypnsF34XK94QjpvRcFGSg/Dc1TopJG2Wfq8hxwtoKerSlL5tyKy0
ZrltxCiLkfVZixwNZEqkg7jPSUvLS299mBrwy+ikmr8CAwEAAaNQME4wHQYDVR0O
BBYEFDiHynoXXjMChfYhc1k7TNtU8ey0MB8GA1UdIwQYMBaAFDiHynoXXjMChfYh
c1k7TNtU8ey0MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAGD9GERC
uJv+oHfMwkNkDV5ZB4F+SQPzXVxDx+rJm1aGJs9PcwPNiV5GweXbvgcnvRAL4h8h
uv3MLQPgVOq0iqp1QPFCoUXxbYYjYzi9FVbR/154sg0uWEHElU2e3fSjcinNRfXD
12232k6HNwSeeZUFQqn2fuk+cae5BsYT8GfsyMq5EfPtG2d8IG+Ji4eEOJeKu4gl
Y33yQnHhw6QKbx8vWaDpZK8qtpapCtLrTtw/nRhX5YV6kMGK+htQUK1etV2O0VQQ
OtDrhOWWaDxQULsHIvCMgTTnZqNQD+Xz4MBm3PGEGi/QUsrEaSQYppb8xxQKZU4X
MyTh7rO5TdNSXmo=
-----END CERTIFICATE-----
PK R] tests/helper/dump.incnu [ $val) {
fprintf($stream, "%s: %s\n", $key, $val);
}
fprintf($stream, "\n");
}
function dump_message($stream, http\Message $msg, $parent = false) {
if (!is_resource($stream)) {
$stream = fopen("php://output", "w");
}
fprintf($stream, "%s\n", $msg->getInfo());
dump_headers($stream, $msg->getHeaders());
$msg->getBody()->toStream($stream);
if ($parent && ($msg = $msg->getParentMessage())) {
dump_message($stream, $msg, true);
}
}
function dump_responses($client, array $expect_cookie = []) {
while (($r = $client->getResponse())) {
dump_headers(null, $r->getHeaders());
if ($expect_cookie) {
$got_cookies = array_merge(...array_map(function($c) {
return $c->getCookies();
}, $r->getCookies()));
if ($expect_cookie != $got_cookies) {
var_dump($expect_cookie, $got_cookies);
echo $r->toString(true);
}
}
}
}
?>
PK R]"lIa a tests/message010.phptnu [ --TEST--
message body
--SKIPIF--
--FILE--
append("foo");
$m->addBody($body);
$body = new http\Message\Body;
$body->append("bar");
$m->addBody($body);
var_dump("foobar" === (string) $m->getBody());
?>
Done
--EXPECT--
Test
bool(true)
Done
PK R]ipU
u u tests/message015.phptnu [ --TEST--
message errors
--SKIPIF--
--FILE--
setRequestUrl("/foo");
} catch (http\Exception $e) {
echo $e->getMessage(),"\n";
}
$m->setType(http\Message::TYPE_REQUEST);
try {
$m->setRequestUrl("");
} catch (http\Exception $e) {
echo $e->getMessage(),"\n";
}
$m = new http\Message;
try {
$m->getParentMessage();
die("unreached");
} catch (http\Exception $e) {
echo $e->getMessage(),"\n";
}
$m = new http\Message("HTTP/1.1 200\r\nHTTP/1.1 201");
try {
$m->prepend($m->getParentMessage());
die("unreached");
} catch (http\Exception $e) {
echo $e->getMessage(),"\n";
}
?>
Done
--EXPECTF--
Test
http\Message is not of type request
Cannot set http\Message's request url to an empty string
http\Message has no parent message
Cannot prepend a message located within the same message chain
Done
PK R]s tests/client032.phptnu [ --TEST--
client cookie sharing enabled
--SKIPIF--
--FILE--
configure(array("share_cookies" => true));
$request = new http\Client\Request("GET", "http://localhost:$port");
$client->enqueue($request);
$client->send();
dump_responses($client, ["counter" => 1]);
/* requeue the previous request */
$client->requeue($request);
$client->send();
dump_responses($client, ["counter" => 2]);
for($i = 3; $i < 6; ++$i) {
/* new requests */
$request = new http\Client\Request("GET", "http://localhost:$port");
$client->enqueue($request);
$client->send();
dump_responses($client, ["counter" => $i]);
}
/* requeue the previous request */
$client->requeue($request);
$client->send();
dump_responses($client, ["counter" => $i]);
});
?>
===DONE===
--EXPECTF--
Test
Etag: ""
Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=2;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=3;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=4;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=5;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=6;
X-Original-Transfer-Encoding: chunked
===DONE===
PK R] tests/bug73055.phptnu [ --TEST--
Bug #73055 (Type confusion vulnerability in merge_param())
--SKIPIF--
--INI--
zend.exception_ignore_args=off
--FILE--
===DONE===
--EXPECTF--
Test
%r(exception ')?%rhttp\Exception\BadQueryStringException%r(' with message '|: )%rhttp\QueryString::__construct(): Max input nesting level of %d exceeded%r'?%r in %sbug73055.php:%d
Stack trace:
#0 %sbug73055.php(%d): http\QueryString->__construct('[[[[[[[[[[[[[[[...')
#1 {main}
===DONE===
PK R]k k k tests/cookie012.phptnu [ --TEST--
cookies cookies
--SKIPIF--
--FILE--
"v1", "c2"=>"v2") === $c->getExtras());
var_dump(array("e0"=>"1", "e2"=>"2") === $c->getCookies());
$c->addCookie("e1", 1);
$c->setCookie("e0");
$c->setCookie("e3", 123);
var_dump("123" === $c->getCookie("e3"));
$c->setCookie("e3");
var_dump(array("e2"=>"2", "e1"=>"1") === $c->getCookies());
var_dump("e2=2; e1=1; c1=v1; c2=v2; " === $c->toString());
$c->addCookies(array("e3"=>3, "e4"=>4));
var_dump(array("e2"=>"2", "e1"=>"1", "e3"=>"3", "e4"=>"4") === $c->getCookies());
var_dump("e2=2; e1=1; e3=3; e4=4; c1=v1; c2=v2; " === $c->toString());
$c->setCookies(array("e"=>"x"));
var_dump(array("e"=>"x") === $c->getCookies());
var_dump("e=x; c1=v1; c2=v2; " === $c->toString());
$c->setCookies();
var_dump(array() === $c->getCookies());
var_dump("c1=v1; c2=v2; " === $c->toString());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
DONE
PK R]F tests/headerparser001.phptnu [ --TEST--
header parser
--SKIPIF--
--FILE--
"FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE");
$parser = new http\Header\Parser;
do {
$state = $parser->parse($part = array_shift($headers),
$headers ? 0 : http\Header\Parser::CLEANUP,
$result);
printf("%2\$-32s | %1\$s\n", $states[$state], addcslashes($part, "\r\n\t\0"));
} while ($headers && $state !== http\Header\Parser::STATE_FAILURE);
var_dump($result);
?>
===DONE===
--EXPECT--
Test
One: | VALUE
header\n | VALUE_EX
Two: header\n\tlines\n | VALUE_EX
Three | KEY
: header\n lines\n here\n | VALUE_EX
More: than one header\n | VALUE_EX
More: | VALUE
than: | VALUE
you: | VALUE
expect\n | VALUE_EX
\n | DONE
array(4) {
["One"]=>
string(6) "header"
["Two"]=>
string(12) "header lines"
["Three"]=>
string(17) "header lines here"
["More"]=>
array(2) {
[0]=>
string(15) "than one header"
[1]=>
string(17) "than: you: expect"
}
}
===DONE===
PK R] tests/cookie003.phptnu [ --TEST--
cookies numeric keys
--SKIPIF--
--FILE--
DONE
--EXPECT--
Test
bool(true)
DONE
PK R]^ ~}m m tests/messagebody010.phptnu [ --TEST--
message body resource
--SKIPIF--
--FILE--
getResource();
var_dump(is_resource($stream));
$stat = fstat($stream);
var_dump(filesize(__FILE__) === $stat["size"]);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK R]jZ2 2 tests/client010.phptnu [ --TEST--
client upload
--SKIPIF--
--FILE--
Array
\(
\[name\] \=\> client010\.php
\[type\] \=\> text\/plain
\[size\] \=\> \d+
\)
\)
)+/';
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
PK R].`=k k tests/urlparser008.phptnu [ --TEST--
url parser ipv6
--SKIPIF--
--FILE--
getMessage(),"\n";
}
}
?>
DONE
--EXPECTF--
Test
s://[a:80
http\Url::__construct(): Failed to parse hostinfo; expected ']' at pos 5 in '[a:80'
s://[0]
http\Url::__construct(): Failed to parse hostinfo; unexpected '[' at pos 0 in '[0]'
s://[::1]:80
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(5) "[::1]"
["port"]=>
int(80)
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://mike@[0:0:0:0:0:FFFF:204.152.189.116]/foo
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "mike"
["pass"]=>
NULL
["host"]=>
string(24) "[::ffff:204.152.189.116]"
["port"]=>
NULL
["path"]=>
string(4) "/foo"
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK R]|n-
-
tests/urlparser009.phptnu [ --TEST--
url parser userinfo
--SKIPIF--
--FILE--
getMessage(),"\n";
}
}
?>
DONE
--EXPECTF--
Test
s://:@
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(0) ""
["pass"]=>
string(0) ""
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://u@
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(1) "u"
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://u:@
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(1) "u"
["pass"]=>
string(0) ""
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://u:p@
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(1) "u"
["pass"]=>
string(1) "p"
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user:pass@
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
string(4) "pass"
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user:pass@host
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
string(4) "pass"
["host"]=>
string(4) "host"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://u@h
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(1) "u"
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user@h
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://u@host
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(1) "u"
["pass"]=>
NULL
["host"]=>
string(4) "host"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user:p@h
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
string(1) "p"
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user:pass@h
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
string(4) "pass"
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://user:pass@host
object(http\Url)#1 (8) {
["scheme"]=>
string(1) "s"
["user"]=>
string(4) "user"
["pass"]=>
string(4) "pass"
["host"]=>
string(4) "host"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK R]}
tests/info002.phptnu [ --TEST--
invalid HTTP info
--SKIPIF--
--INI--
zend.exception_ignore_args=off
--FILE--
===DONE===
--EXPECTF--
Test
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\057' at pos 4 of 'HTTP/1.1 99 Apples in my Basket' in %sinfo002.php:%d
Stack trace:
#0 %sinfo002.php(%d): http\Message->__construct('HTTP/1.1 99 App...')
#1 %sinfo002.php(%d): {%s}()
#2 %sinfo002.php(%d): trap(Object(Closure))
#3 {main}
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\040' at pos 7 of 'CONNECT HTTP/1.1' in %sinfo002.php:%d
Stack trace:
#0 %sinfo002.php(%d): http\Message->__construct('CONNECT HTTP/1....')
#1 %sinfo002.php(%d): {%s}()
#2 %sinfo002.php(%d): trap(Object(Closure))
#3 {main}
HTTP/1.1 200
CONNECT www.example.org:80 HTTP/1.1
===DONE===
PK R]B B tests/params007.phptnu [ --TEST--
urlencoded params
--SKIPIF--
--FILE--
array(
"value" => "b\"r",
"arguments" => array(),
),
"bar" => array(
"value" => "b\"z",
"arguments" => array(),
),
"a[][]" => array(
"value" => "1",
"arguments" => array(),
),
);
var_dump($c === $p->params);
var_dump("foo=b%22r&bar=b%22z&a%5B%5D%5B%5D=1" === (string) $p);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK R]| tests/message012.phptnu [ --TEST--
message part
--SKIPIF--
--FILE--
addHeader("Content-Type", "text/plain");
$p->getBody()->append("data");
$m = new http\Message("HTTP/1.1 200");
$m->getBody()->addPart($p);
echo $m;
?>
Done
--EXPECTF--
Test
HTTP/1.1 200
Content-Length: %d
Content-Type: multipart/form-data; boundary="%x.%x"
--%x.%x
Content-Type: text/plain
Content-Length: 4
data
--%x.%x--
Done
PK R]
tests/client029.phptnu [ --TEST--
client curl user handler
--SKIPIF--
--FILE--
evbase = $evbase;
$this->client = $client;
}
function init($run) {
$this->run = $run;
}
function timer(int $timeout_ms) {
echo "T";
if (isset($this->timeout)) {
$this->timeout->add($timeout_ms/1000);
} else {
$this->timeout = Event::timer($this->evbase, function() {
if (!call_user_func($this->run, $this->client)) {
if ($this->timeout) {
$this->timeout->del();
$this->timeout = null;
}
}
});
$this->timeout->add($timeout_ms/1000);
}
}
function socket($socket, int $action) {
echo "S";
switch ($action) {
case self::POLL_NONE:
break;
case self::POLL_REMOVE:
if (isset($this->ios[(int) $socket])) {
echo "U";
$this->ios[(int) $socket]->del();
unset($this->ios[(int) $socket]);
}
break;
default:
$ev = 0;
if ($action & self::POLL_IN) {
$ev |= Event::READ;
}
if ($action & self::POLL_OUT) {
$ev |= Event::WRITE;
}
if (isset($this->ios[(int) $socket])) {
$this->ios[(int) $socket]->set($this->evbase,
$socket, $ev, $this->onEvent($socket));
} else {
$this->ios[(int) $socket] = new Event($this->evbase,
$socket, $ev, $this->onEvent($socket));
}
break;
}
}
function onEvent($socket) {
return function($watcher, $events) use($socket) {
$action = 0;
if ($events & Ev::READ) {
$action |= self::POLL_IN;
}
if ($events & Ev::WRITE) {
$action |= self::POLL_OUT;
}
if (!call_user_func($this->run, $this->client, $socket, $action)) {
if ($this->timeout) {
$this->timeout->del();
$this->timeout = null;
}
}
};
}
function once() {
throw new BadMethodCallException("this test uses EventBase::loop()");
}
function wait(int $timeout_ms = null) {
throw new BadMethodCallException("this test uses EventBase::loop()");
}
function send() {
throw new BadMethodCallException("this test uses EventBase::loop()");
}
}
include "helper/server.inc";
server("proxy.inc", function($port) {
$evbase = new EventBase;
$client = new http\Client;
$client->configure([
"use_eventloop" => new UserHandler($client, $evbase)
]);
$client->enqueue(new http\Client\Request("GET", "http://localhost:$port/"), function($r) {
var_dump($r->getResponseCode());
});
$evbase->loop();
});
?>
===DONE===
--EXPECTREGEX--
Test
T*[ST]+U+T*int\(200\)
===DONE===
PK R]]ј tests/urlparser003.phptnu [ --TEST--
url parser with query
--SKIPIF--
--FILE--
DONE
--EXPECTF--
Test
s:?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss:?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
s:/?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss:/?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
s://?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss://?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
s://h?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss://hh?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(2) "hh"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
s://h/p?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
string(2) "/p"
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss://hh/pp?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(2) "hh"
["port"]=>
NULL
["path"]=>
string(3) "/pp"
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
s://h:123/p/?q
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
int(123)
["path"]=>
string(3) "/p/"
["query"]=>
string(1) "q"
["fragment"]=>
NULL
}
ss://hh:123/pp/?qq
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(2) "hh"
["port"]=>
int(123)
["path"]=>
string(4) "/pp/"
["query"]=>
string(2) "qq"
["fragment"]=>
NULL
}
DONE
PK R]
fY? tests/message004.phptnu [ --TEST--
message reversal
--SKIPIF--
--FILE--
toString(true);
echo "===\n";
echo newHttpMessage($s)->reverse()->toString(true);
$m = newHttpMessage($s);
$r = $m->reverse();
unset($m);
var_dump($r->count());
echo $r->toString(true);
?>
DONE
--EXPECTF--
GET /first HTTP/1.1
HTTP/1.1 200 Ok-first
GET /second HTTP/1.1
HTTP/1.1 200 Ok-second
GET /third HTTP/1.1
HTTP/1.1 200 Ok-third
===
HTTP/1.1 200 Ok-third
GET /third HTTP/1.1
HTTP/1.1 200 Ok-second
GET /second HTTP/1.1
HTTP/1.1 200 Ok-first
GET /first HTTP/1.1
int(6)
HTTP/1.1 200 Ok-third
GET /third HTTP/1.1
HTTP/1.1 200 Ok-second
GET /second HTTP/1.1
HTTP/1.1 200 Ok-first
GET /first HTTP/1.1
DONE
PK R] tests/urlparser004.phptnu [ --TEST--
url parser multibyte/locale
--SKIPIF--
--FILE--
DONE
--EXPECTF--
Test
sçheme:
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
sçheme://hƟst
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(5) "hƟst"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
sçheme://hƟst:23/päth/öf/fıle
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(5) "hƟst"
["port"]=>
int(23)
["path"]=>
string(16) "/päth/öf/fıle"
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK R]̾ tests/messagebody004.phptnu [ --TEST--
message body add form
--SKIPIF--
--FILE--
addForm(
array(
"foo" => "bar",
"more" => array(
"bah", "baz", "fuz"
),
),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
)
)
);
echo $temp;
?>
DONE
--EXPECTF--
Test
--%x.%x
Content-Disposition: form-data; name="foo"
bar
--%x.%x
Content-Disposition: form-data; name="more[0]"
bah
--%x.%x
Content-Disposition: form-data; name="more[1]"
baz
--%x.%x
Content-Disposition: form-data; name="more[2]"
fuz
--%x.%x
Content-Disposition: form-data; name="upload"; filename="%s"
Content-Transfer-Encoding: binary
Content-Type: text/plain
addForm(
array(
"foo" => "bar",
"more" => array(
"bah", "baz", "fuz"
),
),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
)
)
);
echo $temp;
?>
DONE
--%x.%x--
DONE
PK R]`/
/
tests/message003.phptnu [ --TEST--
multipart message
--SKIPIF--
--FILE--
isMultipart($boundary)) {
var_dump($boundary);
foreach ($m->splitMultipartBody() as $i => $mm) {
echo "==$i==\n",$mm,"===\n";
}
}
?>
DONE
--EXPECTF--
string(40) "----------------------------6e182425881c"
==%d==
Content-Disposition: form-data; name="composer"; filename="composer.json"
Content-Type: application/octet-stream
Content-Length: 567
{
"name": "mike_php_net/autocracy",
"type": "library",
"description": "http\\Controller preserves your autocracy",
"keywords": ["http", "controller", "pecl", "pecl_http"],
"homepage": "http://github.com/mike-php-net/autocracy",
"license": "BSD-2",
"authors": [
{
"name": "Michael Wallner",
"email": "mike@php.net"
}
],
"require": {
"php": ">=5.4.0",
"pecl/pecl_http": "2.*"
},
"autoload": {
"psr-0": {
"http\\Controller": "lib"
}
}
}
===
==%d==
Content-Disposition: form-data; name="LICENSE"; filename="LICENSE"
Content-Type: application/octet-stream
Content-Length: 1354
Copyright (c) 2011-2012, Michael Wallner .
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===
DONE
PK R]V tests/gh-issue42.phptnu [ --TEST--
URL barfs on punycode
--SKIPIF--
--FILE--
===DONE===
--EXPECT--
Test
http://www.xn--kln-sna.de/
===DONE===
PK R]mU*! ! tests/message014.phptnu [ --TEST--
message prepend
--SKIPIF--
--FILE--
prepend($p);
$p = $m;
}
var_dump(
"HTTP/1.1 200\r\n\r\n".
"HTTP/1.1 201\r\n\r\n".
"HTTP/1.1 202\r\n\r\n".
"HTTP/1.1 203\r\n\r\n".
"HTTP/1.1 204\r\n\r\n".
"HTTP/1.1 205\r\n\r\n".
"HTTP/1.1 206\r\n\r\n".
"HTTP/1.1 207\r\n\r\n".
"HTTP/1.1 208\r\n\r\n" ===
$m->toString(true)
);
?>
Done
--EXPECTF--
Test
bool(true)
Done
PK R]vb( tests/message011.phptnu [ --TEST--
message headers
--SKIPIF--
--INI--
date.timezone=UTC
--FILE--
str = $str;
}
function __toString() {
return (string) $this->str;
}
}
$m = new http\Message;
$m->addHeaders(array("foo"=>"bar","bar"=>"foo"));
if (array("Foo"=>"bar", "Bar"=>"foo") !== $m->getHeaders()) {
var_dump($m->getHeaders());
}
$m->addHeaders(array("key"=>"val","more"=>"Stuff"));
if (array("Foo"=>"bar", "Bar"=>"foo","Key"=>"val","More"=>"Stuff") !== $m->getHeaders()) {
var_dump($m->getHeaders());
}
$m = new http\Message("GET / HTTP/1.1");
$m->addHeader("Accept", "text/html");
$m->addHeader("Accept", "text/xml;q=0");
$m->addHeader("Accept", "text/plain;q=0.5");
if (
"GET / HTTP/1.1\r\n".
"Accept: text/html, text/xml;q=0, text/plain;q=0.5\r\n" !==
$m->toString()) {
var_dump($m->toString());
}
$m = new http\Message("HTTP/1.1 200 Ok");
$m->addHeader("Bool", true);
$m->addHeader("Int", 123);
$m->addHeader("Float", 1.23);
$m->addHeader("Array", array(1,2,3));
$m->addHeader("Object", new strval("test"));
$m->addHeader("Set-Cookie",
new http\Cookie(
array(
"cookies" => array("foo" => "bar"),
"expires" => date_create("2012-12-31 22:59:59 GMT")->format(
DateTime::COOKIE
),
"path" => "/somewhere"
)
)
);
$m->addHeader("Set-Cookie", "val=0");
if (
"HTTP/1.1 200 Ok\r\n".
"Bool: true\r\n".
"Int: 123\r\n".
"Float: 1.23\r\n".
"Array: 1, 2, 3\r\n".
"Object: test\r\n".
"Set-Cookie: foo=bar; path=/somewhere; expires=Mon, 31 Dec 2012 22:59:59 GMT; \r\n".
"Set-Cookie: val=0\r\n" !==
$m->toString()) {
var_dump($m->toString());
}
?>
Done
--EXPECT--
Test
Done
PK R]%wc- - tests/url002.phptnu [ --TEST--
url properties
--SKIPIF--
--FILE--
"changed", "query" => "bar&foo=&added=this"),
http\Url::JOIN_PATH |
http\Url::JOIN_QUERY |
http\Url::STRIP_AUTH |
http\Url::STRIP_FRAGMENT
);
var_dump($url->scheme);
var_dump($url->user);
var_dump($url->pass);
var_dump($url->host);
var_dump($url->port);
var_dump($url->path);
var_dump($url->query);
var_dump($url->fragment);
?>
DONE
--EXPECT--
Test
bool(true)
string(4) "http"
NULL
NULL
string(15) "www.example.com"
int(8080)
string(13) "/path/changed"
string(47) "foo=&more%5B0%5D=1&more%5B1%5D=2&bar&added=this"
NULL
DONE
PK R] W tests/client017.phptnu [ --TEST--
client request gzip
--SKIPIF--
--FILE--
setOptions(array("compress" => true));
$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
Etag: "%s"
X-Original-Transfer-Encoding: chunked
X-Original-Content-Encoding: deflate
===DONE===
PK R]ss tests/gh-issue50.phptnu [ --TEST--
segfault with Client::setDebug and Client::dequeue()
--SKIPIF--
--INI--
zend.exception_ignore_args=off
--FILE--
enqueue(new http\Client\Request("GET", "http://example.com"));
$c->setDebug(function(http\Client $c, http\Client\Request $r, $type, $data) {
if ($type & http\Client::DEBUG_HEADER) {
$c->dequeue($r);
}
});
try {
$c->send();
} catch (Exception $e) {
echo $e;
}
?>
===DONE===
--EXPECTF--
Test
http\Exception\RuntimeException: http\Client::dequeue(): Could not dequeue request while executing callbacks in %sgh-issue50.php:9
Stack trace:
#0 %sgh-issue50.php(9): http\Client->dequeue(Object(http\Client\Request))
#1 [internal function]: {closur%s}(Object(http\Client), Object(http\Client\Request), 18, 'GET / HTTP/1.1%s...')
#2 %sgh-issue50.php(14): http\Client->send()
#3 {main}
===DONE===
PK R]E\] ] tests/messagebody001.phptnu [ --TEST--
message body stat
--SKIPIF--
--FILE--
stat("size"));
var_dump(filemtime(__FILE__) === $file->stat("mtime"));
var_dump(fileatime(__FILE__) === $file->stat("atime"));
var_dump(filectime(__FILE__) === $file->stat("ctime"));
var_dump(
(object) array(
"size" => 0,
"mtime" => 0,
"atime" => 0,
"ctime" => 0,
) == $temp->stat()
);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
DONE
PK R]G tests/querystring003.phptnu [ --TEST--
querystring offset set
--SKIPIF--
--FILE--
===DONE===
--EXPECT--
Test
foo=bar&bar=baz
bar=baz&foo=baz
===DONE===
PK R]u[? ? tests/params002.phptnu [ --TEST--
query parser
--SKIPIF--
--FILE--
DONE
--EXPECTF--
object(http\Params)#%d (5) {
["params"]=>
array(2) {
["foo"]=>
array(2) {
["value"]=>
string(3) "bar"
["arguments"]=>
array(0) {
}
}
["arr"]=>
array(2) {
["value"]=>
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
}
["arguments"]=>
array(0) {
}
}
}
["param_sep"]=>
array(2) {
[0]=>
string(1) "&"
[1]=>
string(1) ";"
}
["arg_sep"]=>
string(0) ""
["val_sep"]=>
string(1) "="
["flags"]=>
int(12)
}
foo=bar&arr%5B0%5D=1&arr%5B1%5D=2
DONE
PK R]dV+T T tests/messageparser001.phptnu [ --TEST--
message parser
--SKIPIF--
--FILE--
parse(fgets($fd), 0, $message)) {
case Parser::STATE_DONE:
$string = (string) $message;
break 2;
case Parser::STATE_FAILURE:
throw new Exception(($e = error_get_last()) ? $e["message"] : "Could not parse $file");
}
}
if (!$string) {
$s = array("START", "HEADER", "HEADER_DONE", "BODY", "BODY_DUMB", "BODY_LENGTH", "BODY_CHUNK", "BODY_DONE", "UPDATE_CL", "DONE");
printf("Unexpected state: %s (%s)\n", $s[$parser->getState()], $file);
}
$parser = new Parser;
rewind($fd);
unset($message);
switch ($parser->stream($fd, 0, $message)) {
case Parser::STATE_DONE:
case Parser::STATE_START:
break;
default:
printf("Expected parser state 0 or 8, got %d", $parser->getState());
}
if ($string !== (string) $message) {
$a = explode("\n", $string);
$b = explode("\n", (string) $message);
do {
$aa = array_shift($a);
$bb = array_shift($b);
if ($aa !== $bb) {
isset($aa) and printf("-- %s\n", $aa);
isset($bb) and printf("++ %s\n", $bb);
}
} while ($a || $b);
}
}
?>
DONE
--EXPECT--
Test
DONE
PK R] tests/message007.phptnu [ --TEST--
message to stream
--SKIPIF--
--FILE--
addHeader("Content-Type", "text/plain");
$m->getBody()->append("this\nis\nthe\ntext");
$f = tmpfile();
$m->toStream($f);
rewind($f);
var_dump((string) $m === stream_get_contents($f));
fclose($f);
?>
Done
--EXPECT--
Test
bool(true)
Done
PK R] tests/version001.phptnu [ --TEST--
version parse error
--SKIPIF--
--FILE--
setHttpVersion("1-1");
$m->setHttpVersion("one.one");
} catch (http\Exception $e) {
echo $e->getMessage(),"\n";
}
?>
--EXPECTF--
Notice: http\Message::setHttpVersion(): Non-standard version separator '-' in HTTP protocol version '1-1' in %s
http\Message::setHttpVersion(): Could not parse HTTP protocol version 'one.one'
PK R]) tests/client024.phptnu [ --TEST--
client deprecated methods
--SKIPIF--
--FILE--
enableEvents(false);
$client->enablePipelining(false);
?>
===DONE===
--EXPECTF--
Test
Deprecated: Method http\Client::enableEvents() is deprecated in %sclient024.php on line %d
Deprecated: Method http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
===DONE===
PK R]o tests/params015.phptnu [ --TEST--
header params rfc5987 regression
--SKIPIF--
--FILE--
array("filename"=>"foo.bar")));
var_dump($p->params);
var_dump((string)$p);
?>
===DONE===
--EXPECT--
Test
array(1) {
["attachment"]=>
array(1) {
["filename"]=>
string(7) "foo.bar"
}
}
string(27) "attachment;filename=foo.bar"
===DONE===
PK R]& & tests/client014.phptnu [ --TEST--
reset content length when resetting body
--SKIPIF--
--FILE--
setBody(new http\Message\Body(fopen(__FILE__, "r")));
$client->enqueue($request);
var_dump($request->getHeader("Content-Length"));
$request->setBody(new http\Message\Body);
$client->requeue($request);
var_dump($request->getHeader("Content-Length"));
?>
===DONE===
--EXPECTF--
Test
int(379)
bool(false)
===DONE===
PK R]i| | tests/cookie008.phptnu [ --TEST--
cookies path
--SKIPIF--
--FILE--
getCookie("this"));
var_dump((string)$c);
var_dump($c->getPath());
$o = clone $c;
$p = "/up";
$o->setPath();
var_dump($o->getPath());
var_dump($c->getPath());
$o->setPath($p);
var_dump($o->getPath());
var_dump($c->getPath());
var_dump($o->toString());
?>
DONE
--EXPECT--
Test
string(10) "has a path"
string(33) "this=has%20a%20path; path=/down; "
string(5) "/down"
NULL
string(5) "/down"
string(3) "/up"
string(5) "/down"
string(31) "this=has%20a%20path; path=/up; "
DONE
PK R]f9F tests/etag001.phptnu [ --TEST--
etags with hash
--SKIPIF--
--FILE--
append("Hello, my old fellow.");
foreach (["md5", "sha1", "sha256"] as $algo) {
if (strncmp($algo, "sha3-", 5) && strncmp($algo, "sha512/", 7) && strcmp($algo, "crc32c")) {
ini_set("http.etag.mode", $algo);
printf("%10s: %s\n",
$algo,
$body->etag()
);
}
}
?>
DONE
--EXPECT--
md5: 6ce3cc8f3861fb7fd0d77739f11cd29c
sha1: ad84012eabe27a61762a97138d9d2623f4f1a7a9
sha256: ed9ecfe5c76d51179c3c1065916fdb8d94aee05577f187bd763cdc962bba1f42
DONE
PK R]$r tests/clientresponse001.phptnu [ --TEST--
client response cookie
--SKIPIF--
--FILE--
enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
var_dump($cookies->toArray());
}
}
});
?>
Done
--EXPECTREGEX--
Test
(?:array\(7\) \{\n \["cookies"\]\=\>\n array\(2\) \{\n \["foo"\]\=\>\n string\(3\) "bar"\n \["bar"\]\=\>\n string\(3\) "foo"\n \}\n \["extras"\]\=\>\n array\(0\) \{\n \}\n \["flags"\]\=\>\n int\(0\)\n \["expires"\]\=\>\n int\(\-1\)\n \["max\-age"\]\=\>\n int\(\-1\)\n \["path"\]\=\>\n string\(0\) ""\n \["domain"\]\=\>\n string\(0\) ""\n\}\n)+Done
PK R]/! tests/urlparser012.phptnu [ --TEST--
url parser multibyte/locale/topct
--SKIPIF--
--FILE--
DONE
--EXPECTF--
Test
object(http\Url)#%d (8) {
["scheme"]=>
string(4) "http"
["user"]=>
string(4) "mike"
["pass"]=>
string(12) "pa%C3%9Fwort"
["host"]=>
string(13) "xn--097ccd.it"
["port"]=>
NULL
["path"]=>
string(15) "/for/%E2%82%AC/"
["query"]=>
string(9) "by=%C2%A2"
["fragment"]=>
string(6) "%C3%B8"
}
DONE
PK R])3 3 tests/params003.phptnu [ --TEST--
default params
--SKIPIF--
--FILE--
"arg", "bar"=>"bla", "gotit"=>"now");
$r = array (
'foo' =>
array (
'value' => true,
'arguments' =>
array (
),
),
'bar' =>
array (
'value' => true,
'arguments' =>
array (
'arg' => '0',
'bla' => true,
),
),
'gotit' =>
array (
'value' => '0',
'arguments' =>
array (
'now' => true,
),
),
);
# ---
var_dump(count($p->params));
echo "key exists\n";
foreach ($k as $key) {
var_dump(array_key_exists($key, $p->params));
}
echo "values\n";
foreach ($k as $key) {
var_dump($p[$key]["value"]);
}
echo "args\n";
foreach ($k as $key) {
var_dump(count($p[$key]["arguments"]));
}
echo "arg values\n";
foreach ($k as $key) {
var_dump(@$p[$key]["arguments"][$a[$key]]);
}
echo "equals\n";
var_dump($c === (string) $p);
var_dump($r === $p->params);
$x = new http\Params($p->params);
var_dump($r === $x->toArray());
?>
DONE
--EXPECT--
Test
int(3)
key exists
bool(true)
bool(true)
bool(true)
values
bool(true)
bool(true)
string(1) "0"
args
int(0)
int(2)
int(1)
arg values
NULL
bool(true)
bool(true)
equals
bool(true)
bool(true)
bool(true)
DONE
PK R]77 7 tests/serialize001.phptnu [ --TEST--
serialization
--SKIPIF--
--FILE--
getClasses() as $class) {
if ($class->isInstantiable()) {
#printf("%s\n", $class->getName());
$instance = $class->newInstance();
$serialized = serialize($instance);
$unserialized = unserialize($serialized);
foreach (array("toString", "toArray") as $m) {
if ($class->hasMethod($m)) {
#printf("%s#%s\n", $class->getName(), $m);
$unserialized->$m();
}
}
}
}
?>
DONE
--EXPECTF--
DONE
PK R]釃) tests/cookie010.phptnu [ --TEST--
cookies flags
--SKIPIF--
--FILE--
getFlags() & http\Cookie::SECURE));
var_dump(http\Cookie::HTTPONLY === ($c->getFlags() & http\Cookie::HTTPONLY));
$c->setFlags($c->getFlags() ^ http\Cookie::SECURE);
var_dump(!($c->getFlags() & http\Cookie::SECURE));
var_dump(http\Cookie::HTTPONLY === ($c->getFlags() & http\Cookie::HTTPONLY));
$c->setFlags($c->getFlags() ^ http\Cookie::HTTPONLY);
var_dump(!($c->getFlags() & http\Cookie::SECURE));
var_dump(!($c->getFlags() & http\Cookie::HTTPONLY));
var_dump("icanhas=flags; " === $c->toString());
$c->setFlags(http\Cookie::SECURE|http\Cookie::HTTPONLY);
var_dump("icanhas=flags; secure; httpOnly; " === $c->toString());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
DONE
PK R]0ܙ tests/clientresponse002.phptnu [ --TEST--
client response cookies
--SKIPIF--
--FILE--
enqueue($request)->send()->getResponse()->getCookies(0, array("comment")) as $cookies) {
var_dump($cookies->toArray());
}
}
});
?>
Done
--EXPECTREGEX--
Test
(?:array\(7\) \{\n \["cookies"\]\=\>\n array\(1\) \{\n \["temp"\]\=\>\n string\(1\d\) "\d+\.\d+"\n \}\n \["extras"\]\=\>\n array\(0\) \{\n \}\n \["flags"\]\=\>\n int\(0\)\n \["expires"\]\=\>\n int\(\-1\)\n \["max\-age"\]\=\>\n int\(\-1\)\n \["path"\]\=\>\n string\(0\) ""\n \["domain"\]\=\>\n string\(0\) ""\n\}\narray\(7\) \{\n \["cookies"\]\=\>\n array\(1\) \{\n \["perm"\]\=\>\n string\(1\d\) "\d+\.\d+"\n \}\n \["extras"\]\=\>\n array\(0\) \{\n \}\n \["flags"\]\=\>\n int\(0\)\n \["expires"\]\=\>\n int\(\d+\)\n \["max\-age"\]\=\>\n int\(\-1\)\n \["path"\]\=\>\n string\(0\) ""\n \["domain"\]\=\>\n string\(0\) ""\n\}\n)+Done
PK R]SV{ { tests/client025.phptnu [ --TEST--
client seek
--SKIPIF--
--FILE--
setOptions(array("resume" => 1, "expect_100_timeout" => 0));
$request->getBody()->append("123");
dump_message(null, $client->enqueue($request)->send()->getResponse());
});
// Content-length is 2 instead of 3 in older libcurls
?>
===DONE===
--EXPECTF--
Test
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: %d
Etag: "%x"
X-Original-Transfer-Encoding: chunked
X-Request-Content-Length: 2
PUT / HTTP/1.1
Accept: */*
Content-Length: %d
Content-Range: bytes 1-2/3
%r(Expect: 100-continue
)?%rHost: localhost:%d
User-Agent: %s
X-Original-Content-Length: %d
23===DONE===
PK R]#\ tests/client007.phptnu [ --TEST--
client response callback + requeue
--SKIPIF--
--FILE--
requeue($request, "response");
$client->send();
}
}
});
?>
Done
--EXPECTREGEX--
Test
(?:R
R
)+Done
PK R]Do o tests/clientresponse003.phptnu [ --TEST--
client response transfer info
--SKIPIF--
--FILE--
enqueue($request)->send()->getResponse();
var_dump($response->getTransferInfo("response_code"));
var_dump(count((array)$response->getTransferInfo()));
}
});
?>
Done
--EXPECTREGEX--
Test
(?:int\([1-5]\d\d\)
int\(\d\d\)
)+Done
PK R]׆\ \ tests/gh-issue92.phptnu [ --TEST--
gh-issue #93: message body add form ignores numeric indices
--SKIPIF--
--FILE--
addForm(
array("foo", "bar", "baz"),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
),
"dir" => array(
array(
"file" => __FILE__,
"name" => 1,
"type" => "text/plain",
),
array(
"file" => __FILE__,
"name" => 2,
"type" => "text/plain",
),
),
)
);
echo $temp;
?>
DONE
--EXPECTF--
Test
--%x.%x
Content-Disposition: form-data; name="0"
foo
--%x.%x
Content-Disposition: form-data; name="1"
bar
--%x.%x
Content-Disposition: form-data; name="2"
baz
--%x.%x
Content-Disposition: form-data; name="upload"; filename="gh-issue92.php"
Content-Transfer-Encoding: binary
Content-Type: text/plain
addForm(
array("foo", "bar", "baz"),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
),
"dir" => array(
array(
"file" => __FILE__,
"name" => 1,
"type" => "text/plain",
),
array(
"file" => __FILE__,
"name" => 2,
"type" => "text/plain",
),
),
)
);
echo $temp;
?>
DONE
--%x.%x
Content-Disposition: form-data; name="dir[1]"; filename="gh-issue92.php"
Content-Transfer-Encoding: binary
Content-Type: text/plain
addForm(
array("foo", "bar", "baz"),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
),
"dir" => array(
array(
"file" => __FILE__,
"name" => 1,
"type" => "text/plain",
),
array(
"file" => __FILE__,
"name" => 2,
"type" => "text/plain",
),
),
)
);
echo $temp;
?>
DONE
--%x.%x
Content-Disposition: form-data; name="dir[2]"; filename="gh-issue92.php"
Content-Transfer-Encoding: binary
Content-Type: text/plain
addForm(
array("foo", "bar", "baz"),
array(
array(
"file" => __FILE__,
"name" => "upload",
"type" => "text/plain",
),
"dir" => array(
array(
"file" => __FILE__,
"name" => 1,
"type" => "text/plain",
),
array(
"file" => __FILE__,
"name" => 2,
"type" => "text/plain",
),
),
)
);
echo $temp;
?>
DONE
--%x.%x--
DONE
PK R]0 0 tests/client004.phptnu [ --TEST--
client reset
--SKIPIF--
--FILE--
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);
}
});
?>
Done
--EXPECTREGEX--
Test
(?:Failed to enqueue request; request already in queue
)+Done
PK R]Y` tests/messagebody003.phptnu [ --TEST--
message body append error
--SKIPIF--
--INI--
zend.exception_ignore_args=off
--FILE--
append("nope");
} catch (Exception $e) {
echo $e, "\n";
}
?>
DONE
--EXPECTF--
Test
http\Exception\RuntimeException: http\Message\Body::append(): Failed to append 4 bytes to body; wrote 0 in %s:%d
Stack trace:
#0 %s(%d): http\Message\Body->append('nope')
#1 {main}
DONE
PK R]-1$ tests/skipif.incnu [ =")) {
die("skip need at least libcurl version $version\n");
}
}
function skip_http2_test($message = "skip need http2 support") {
if (!defined("http\\Client\\Curl\\HTTP_VERSION_2_0")) {
die("$message (HTTP_VERSION_2_0)\n");
}
if (!(http\Client\Curl\FEATURES & http\Client\Curl\Features\HTTP2)) {
die("$message (FEATURES & HTTP2)\n");
}
foreach (explode(":", getenv("PATH")) as $path) {
if (is_executable($path . "/nghttpd")) {
return;
}
}
die("$message (nghttpd in PATH)\n");
}
PK R]:y tests/client011.phptnu [ --TEST--
client history
--SKIPIF--
--FILE--
append("foobar");
$request = new http\Client\Request;
$request->setBody($body);
$request->setRequestMethod("POST");
$request->setRequestUrl("http://localhost:$port");
$client = new http\Client;
$client->recordHistory = true;
$client->enqueue($request)->send();
echo $client->getHistory()->toString(true);
$client->requeue($request)->send();
echo $client->getHistory()->toString(true);
});
?>
Done
--EXPECTF--
Test
POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
Accept-Ranges: bytes
X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
string(6) "foobar"
POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
Accept-Ranges: bytes
X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
string(6) "foobar"
POST http://localhost:%d/ HTTP/1.1
Content-Length: 6
foobar
HTTP/1.1 200 OK
Accept-Ranges: bytes
X-Request-Content-Length: 6
X-Original-Transfer-Encoding: chunked
Content-Length: 19
string(6) "foobar"
Done
PK R].% tests/client002.phptnu [ --TEST--
client observer
--SKIPIF--
--FILE--
getProgressInfo($request);
if ($progress->info !== "prepare" && $compare && $compare != $progress) {
var_dump($progress, $compare);
}
}
}
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();
}
});
?>
Done
--EXPECTREGEX--
Test
P+
Done
PK R]|= tests/messagebody002.phptnu [ --TEST--
message body append
--SKIPIF--
--FILE--
append("yes");
var_dump((string) $temp);
?>
DONE
--EXPECT--
Test
string(3) "yes"
DONE
PK R]6K K tests/filterchunked.phptnu [ --TEST--
chunked filter
--SKIPIF--
--FILE--
DONE
--EXPECT--
DONE
PK R]_?a a tests/bug66388.phptnu [ --TEST--
Bug #66388 (Crash on POST with Content-Length:0 and untouched body)
--SKIPIF--
--FILE--
0
)
);
$client->setOptions(["timeout" => 30]);
$client->enqueue($request);
echo $client->send()->getResponse()->getResponseCode();
});
?>
===DONE===
--EXPECTF--
Test
200
===DONE===
PK R]1 1 tests/header007.phptnu [ --TEST--
header parse error
--SKIPIF--
--FILE--
Done
--EXPECTF--
Test
Warning: http\Header::parse(): Failed to parse headers: unexpected end of line at pos 4 of 'wass\nup' in %s on line %d
Done
PK R]$7
tests/header004.phptnu [ --TEST--
header match
--SKIPIF--
--FILE--
match("gzip", http\Header::MATCH_WORD));
var_dump($ae->match("gzip", http\Header::MATCH_WORD|http\Header::MATCH_CASE));
var_dump($ae->match("gzip", http\Header::MATCH_STRICT));
var_dump($ae->match("deflate", http\Header::MATCH_WORD));
var_dump($ae->match("deflate", http\Header::MATCH_WORD|http\Header::MATCH_CASE));
var_dump($ae->match("deflate", http\Header::MATCH_STRICT));
var_dump($ae->match("zip", http\Header::MATCH_WORD));
var_dump($ae->match("gzip", http\Header::MATCH_FULL));
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
Done
PK R]{ tests/urlparser007.phptnu [ --TEST--
url parser multibyte/utf-8/idna
--SKIPIF--
--FILE--
DONE
--EXPECTF--
Test
sçheme:
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
sçheme://hƟst
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(11) "xn--hst-kwb"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
sçheme://hƟst:23/päth/öf/fıle
object(http\Url)#%d (8) {
["scheme"]=>
string(7) "sçheme"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(11) "xn--hst-kwb"
["port"]=>
int(23)
["path"]=>
string(16) "/päth/öf/fıle"
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK R]!> tests/header006.phptnu [ --TEST--
header parsing
--SKIPIF--
--FILE--
"bar","Bar"=>"foo") === http\Header::parse($header));
$headers = http\Header::parse($header, "http\\Header");
var_dump(2 === count($headers));
var_dump(2 === array_reduce($headers, function($count, $header) {
return $count + ($header instanceof http\Header);
}, 0));
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
Done
PK R]8㸒 tests/header009.phptnu [ --TEST--
header params w/ args
--SKIPIF--
--FILE--
array("value" => "bar", "arguments" => array()),
"bar" => array("value" => "bis", "arguments" => array("bis" => "where"))
) === $header->getParams(".", "where", "is")->params
);
?>
Done
--EXPECT--
Test
bool(true)
Done
PK R]kI I tests/bug69357.phptnu [ --TEST--
Bug #69357 (HTTP/1.1 100 Continue overriding subsequent 200 response code with PUT request)
--SKIPIF--
--FILE--
append("foo");
$r = new \http\Client\Request("PUT", "http://localhost:$port/", array(), $b);
$c = new \http\Client;
$c->setOptions(array("expect_100_timeout" => 0));
$c->enqueue($r)->send();
var_dump($c->getResponse($r)->getInfo());
var_dump($c->getResponse($r)->getHeaders());
});
?>
===DONE===
--EXPECTF--
Test
string(15) "HTTP/1.1 200 OK"
array(4) {
["Accept-Ranges"]=>
string(5) "bytes"
["Etag"]=>
string(10) ""%x""
["X-Original-Transfer-Encoding"]=>
string(7) "chunked"
["Content-Length"]=>
int(%d)
}
===DONE===
PK R]x tests/message013.phptnu [ --TEST--
message detach
--SKIPIF--
--FILE--
detach();
var_dump(3 === count($m));
var_dump(1 === count($d));
var_dump("HTTP/1.1 302 Found\r\n\r\n" === $d->toString(true));
?>
Done
--EXPECTF--
Test
bool(true)
bool(true)
bool(true)
bool(true)
Done
PK R]ꋽ tests/header005.phptnu [ --TEST--
header negotiation
--SKIPIF--
--FILE--
negotiate(array("text/plain","text/html")));
var_dump("text/html" === $a->negotiate(array("text/plain","text/html"), $rs));
var_dump(array("text/html"=>0.99, "text/plain"=>0.5) === array_map("r", $rs));
var_dump("text/plain" === $a->negotiate(array("foo/bar", "text/plain"), $rs));
var_dump(array("text/plain"=>0.5) === array_map("r", $rs));
var_dump("foo/bar" === $a->negotiate(array("foo/bar"), $rs));
var_dump(array() === $rs);
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Done
PK R]KH] ] tests/bug69313.phptnu [ --TEST--
Bug #69313 (http\Client doesn't send GET body)
--SKIPIF--
--FILE--
setHeader("Content-Type", "text/plain");
$request->getBody()->append("foo");
$client = new http\Client();
$client->enqueue($request);
$client->send();
dump_message(null, $client->getResponse());
});
?>
Done
--EXPECTF--
Test
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: %d
Etag: "%s"
X-Original-Transfer-Encoding: chunked
X-Request-Content-Length: 3
GET / HTTP/1.1
Accept: */*
Content-Length: 3
Content-Type: text/plain
Host: localhost:%d
User-Agent: %s
X-Original-Content-Length: 3
foo
Done
PK R]/ tests/params017.phptnu [ --TEST--
header params rfc5988
--SKIPIF--
--FILE--
;
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
;
rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
EOF;
$p = current(http\Header::parse($link, "http\\Header"))->getParams(
http\Params::DEF_PARAM_SEP,
http\Params::DEF_ARG_SEP,
http\Params::DEF_VAL_SEP,
http\Params::PARSE_RFC5987 | http\Params::PARSE_RFC5988 | http\Params::PARSE_ESCAPED
);
var_dump($p->params);
var_dump((string)$p);
?>
===DONE===
--EXPECTF--
Test
array(2) {
["/TheBook/chapter2"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(2) {
["rel"]=>
string(8) "previous"
["*rfc5987*"]=>
array(1) {
["title"]=>
array(1) {
["de"]=>
string(15) "letztes Kapitel"
}
}
}
}
["/TheBook/chapter4"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(2) {
["rel"]=>
string(4) "next"
["*rfc5987*"]=>
array(1) {
["title"]=>
array(1) {
["de"]=>
string(17) "nächstes Kapitel"
}
}
}
}
}
string(139) ";rel="previous";title*=utf-8'de'letztes%20Kapitel,;rel="next";title*=utf-8'de'n%C3%A4chstes%20Kapitel"
===DONE===
PK R]"Ga tests/params013.phptnu [ --TEST--
header params rfc5987
--SKIPIF--
--FILE--
params, (string) $p);
$p = new http\Params("bar; title*=iso-8859-1'en'%A3%20rates");
var_dump($p->params, (string) $p);
$p = new http\Params("bar; title*=UTF-8''%c2%a3%20and%20%e2%82%ac%20rates");
var_dump($p->params, (string) $p);
?>
===DONE===
--EXPECT--
Test
array(1) {
["attachment"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["*rfc5987*"]=>
array(1) {
["filename"]=>
array(1) {
[""]=>
string(10) "döner.pdf"
}
}
}
}
}
string(42) "attachment;filename*=utf-8''d%C3%B6ner.pdf"
array(1) {
["bar"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["*rfc5987*"]=>
array(1) {
["title"]=>
array(1) {
["en"]=>
string(8) "£ rates"
}
}
}
}
}
string(34) "bar;title*=utf-8'en'%C2%A3%20rates"
array(1) {
["bar"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["*rfc5987*"]=>
array(1) {
["title"]=>
array(1) {
[""]=>
string(16) "£ and € rates"
}
}
}
}
}
string(50) "bar;title*=utf-8''%C2%A3%20and%20%E2%82%AC%20rates"
===DONE===
PK R]H tests/client020.phptnu [ --TEST--
client proxy - don't send proxy headers for a standard request
--SKIPIF--
--FILE--
setOptions(array(
"timeout" => 3,
"proxyheader" => array("Hello" => "there!"),
));
try {
$c->enqueue($r)->send();
} catch (Exception $e) {
echo $e;
}
echo $c->getResponse()->getBody();
unset($r, $client);
});
?>
===DONE===
--EXPECTF--
Test
Server on port %d
GET / HTTP/1.1
Accept: */*
Host: localhost:%d
User-Agent: PECL_HTTP/%s PHP/%s libcurl/%s
===DONE===
PK R]F tests/client022.phptnu [ --TEST--
client http2
--SKIPIF--
--FILE--
setOptions([
"protocol" => http\Client\Curl\HTTP_VERSION_2_0,
"ssl" => [
"cainfo" => __DIR__."/helper/http2.crt",
"verifypeer" => false, // needed for NSS without PEM support
]
]);
$request = new http\Client\Request("GET", "https://localhost:$port");
$client->enqueue($request);
echo $client->send()->getResponse();
});
?>
===DONE===
--EXPECTF--
Test
HTTP/2 200
%a
HTTP2
Nothing to see here.
===DONE===
PK R]& & tests/info001.phptnu [ --TEST--
invalid HTTP info
--SKIPIF--
--INI--
zend.exception_ignore_args=off
--FILE--
DONE
--EXPECTF--
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\040' at pos 3 of 'GET HTTP/1.1' in %s
Stack trace:
#0 %s: http\Message->__construct('GET HTTP/1.1')
#1 {main}
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\040' at pos 3 of 'GET HTTP/1.123' in %s
Stack trace:
#0 %s: http\Message->__construct('GET HTTP/1.123')
#1 {main}
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\057' at pos 7 of 'GETHTTP/1.1' %s
Stack trace:
#0 %s: http\Message->__construct('GETHTTP/1.1')
#1 {main}
object(http\Message)#%d (9) {
["type":protected]=>
int(1)
["body":protected]=>
NULL
["requestMethod":protected]=>
string(3) "GET"
["requestUrl":protected]=>
string(1) "/"
["responseStatus":protected]=>
string(0) ""
["responseCode":protected]=>
int(0)
["httpVersion":protected]=>
string(3) "1.1"
["headers":protected]=>
array(0) {
}
["parentMessage":protected]=>
NULL
}
DONE
PK R]2yTr tests/client012.phptnu [ --TEST--
client ssl
--SKIPIF--
--FILE--
setSslOptions(array("verifypeer" => true));
$client->addSslOptions(array("verifyhost" => 2));
var_dump(
array(
"verifypeer" => true,
"verifyhost" => 2,
) === $client->getSslOptions()
);
$client->attach($observer = new class implements SplObserver {
public $data = [];
#[ReturnTypeWillChange]
function update(SplSubject $client, $req = null, $progress = null) {
$ti = $client->getTransferInfo($req);
if (isset($ti->tls_session["internals"])) {
foreach ((array) $ti->tls_session["internals"] as $key => $val) {
if (!isset($this->data[$key]) || $this->data[$key] < $val) {
$this->data[$key] = $val;
}
}
}
}
});
$client->enqueue($req = new http\Client\Request("GET", "https://twitter.com/"));
$client->send();
switch ($client->getTransferInfo($req)->tls_session["backend"]) {
case "openssl":
case "gnutls":
if (count($observer->data) < 1) {
printf("%s: failed count(ssl.internals) >= 1\n", $client->getTransferInfo($req)->tls_session["backend"]);
var_dump($observer);
exit;
}
break;
default:
break;
}
?>
Done
--EXPECTF--
Test
bool(true)
Done
PK R]GU tests/params011.phptnu [ --TEST--
bool args params
--SKIPIF--
--FILE--
false, "arguments" => array("wrong" => false, "correct" => true));
$p["container"] = $container;
var_dump("container=0;wrong=0;correct" === $p->toString());
var_dump(array("container" => $container) === $p->toArray());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK R]߆! ! tests/params012.phptnu [ --TEST--
no args params
--SKIPIF--
--FILE--
toString());
$p["param"] = false;
var_dump("param=0" === $p->toString());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK R]K% tests/headerparser003.phptnu [ --TEST--
header parser with nonblocking stream
--SKIPIF--
--FILE--
stream($socket[0], 0, $hdrs);
fwrite($socket[1], $line);
var_dump($parser->getState());
var_dump($parser->stream($socket[0], 0, $hdrs));
}
var_dump($hdrs);
?>
DONE
--EXPECT--
Test
int(0)
int(1)
int(1)
int(2)
int(2)
int(3)
int(3)
int(1)
int(1)
int(3)
int(3)
int(5)
array(2) {
["Host"]=>
string(9) "localhost"
["Content-Length"]=>
string(1) "3"
}
DONE
PK R]!V tests/messagebody006.phptnu [ --TEST--
message body etag
--SKIPIF--
--INI--
http.etag.mode = crc32b
--FILE--
etag()
);
var_dump($temp->etag());
?>
DONE
--EXPECT--
Test
bool(true)
string(8) "00000000"
DONE
PK R]D1X X tests/client009.phptnu [ --TEST--
client static cookies
--SKIPIF--
--FILE--
setCookies(array("test" => "bar"));
$client->addCookies(array("foo" => "test"));
$request = new http\Client\Request("GET", "http://localhost:$port");
$client->enqueue($request);
$client->send();
echo $client->getResponse()->getBody()->toString();
$request->setOptions(array("cookies" => x($client->getCookies())));
$client->requeue($request);
$client->send();
echo $client->getResponse()->getBody()->toString();
});
?>
Done
--EXPECT--
Test
Array
(
[test] => bar
[foo] => test
)
Array
(
[test] => test
[foo] => bar
)
Done
PK R]a84! tests/bug69076.phptnu [ --TEST--
Bug #69076 (URL parsing throws exception on empty query string)
--SKIPIF--
--FILE--
===DONE===
--EXPECT--
Test
http://foo.bar/
===DONE===
PK R]`@B& tests/clientrequest003.phptnu [ --TEST--
client request query
--SKIPIF--
--FILE--
getQuery());
var_dump($r === $r->setQuery($q = "foo=bar"));
var_dump($q === $r->getQuery());
var_dump($r === $r->addQuery("a[]=1&a[]=2"));
var_dump("foo=bar&a%5B0%5D=1&a%5B1%5D=2" === $r->getQuery());
var_dump(null === $r->setQuery(null)->getQuery());
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Done
PK R]*&l l tests/querystring002.phptnu [ --TEST--
query string
--SKIPIF--
--FILE--
get());
printf("Get defval\n");
var_dump("nonexistant" === $q->get("unknown", "s", "nonexistant"));
var_dump(null === $q->get("unknown"));
printf("Get 'a'\n");
var_dump("b" === $q->get("a"));
var_dump(0 === $q->get("a", "i"));
var_dump(array("b") === $q->get("a", "a"));
var_dump((object)array("scalar" => "b") == $q->get("a", "o"));
printf("Get 'r'\n");
var_dump(array("0","1","2") === $q->get("r"));
printf("Get 'rr'\n");
var_dump(array(array("00","01")) === $q->get("rr"));
printf("Get 1\n");
var_dump(2 == $q->get(1));
var_dump("2" === $q->get(1, "s"));
var_dump(2.0 === $q->get(1, "f"));
var_dump($q->get(1, "b"));
printf("Del 'a'\n");
var_dump("b" === $q->get("a", http\QueryString::TYPE_STRING, null, true));
var_dump(null === $q->get("a"));
printf("Del all\n");
$q->set(array("a" => null, "r" => null, "rr" => null, 1 => null));
var_dump("" === $q->toString());
$q = new http\QueryString($s);
printf("QSO\n");
var_dump($e === (string) new http\QueryString($q));
var_dump(http_build_query(array("e"=>$q->toArray())) === (string) new http\QueryString(array("e" => $q)));
printf("Iterator\n");
var_dump($q->toArray() === iterator_to_array($q));
printf("Serialize\n");
var_dump($e === (string) unserialize(serialize($q)));
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
Get defval
bool(true)
bool(true)
Get 'a'
bool(true)
bool(true)
bool(true)
bool(true)
Get 'r'
bool(true)
Get 'rr'
bool(true)
Get 1
bool(true)
bool(true)
bool(true)
bool(true)
Del 'a'
bool(true)
bool(true)
Del all
bool(true)
QSO
bool(true)
bool(true)
Iterator
bool(true)
Serialize
bool(true)
DONE
PK R] tests/cookie001.phptnu [ --TEST--
cookies empty state
--SKIPIF--
--FILE--
array(),
"extras" => array(),
"flags" => 0,
"expires" => -1,
"path" => "",
"domain" => "",
"max-age" => -1,
);
var_dump($a == $c->toArray());
var_dump($a == $o->toArray());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK R]Gv^ tests/cookie004.phptnu [ --TEST--
cookies raw
--SKIPIF--
--FILE--
DONE
--EXPECT--
Test
bool(true)
DONE
PK R]p}6 6 tests/client001.phptnu [ --TEST--
client drivers
--SKIPIF--
--FILE--
Done
--EXPECTREGEX--
Test
(?:bool\(true\)
)+Done
PK R]Ծ~ ~ tests/bug61444.phptnu [ --TEST--
Bug #61444 (. become _ in query strings due to php_default_treat_data())
--SKIPIF--
--FILE--
'utm_source=changed'), http\Url::JOIN_QUERY), PHP_EOL, PHP_EOL;
// Replacing the host
echo new http\Url($url, array('host' => 'www.google.com')), PHP_EOL, PHP_EOL;
// Generating a query string from scratch
echo new http\QueryString(array(
'bar.baz' => 'blah',
'utm_source' => 'google',
'utm_campaign' => 'somethingelse',
'blat' => null,
)), PHP_EOL, PHP_EOL;
?>
DONE
--EXPECT--
http://www.example.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat
http://www.example.com/foobar?bar.baz=blah&utm_source=changed&utm_campaign=somethingelse&blat
http://www.google.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat
bar.baz=blah&utm_source=google&utm_campaign=somethingelse
DONE
PK R]'
tests/gh-issue63.phptnu [ --TEST--
gh issue #63: Url::mod() breaks query strings containing plus-notation spaces in the input URL
--SKIPIF--
--FILE--
'bar'];
$parts['query'] = new QueryString($query);
echo (new Url($url, null, Url::STDFLAGS))->mod($parts)->toString();
?>
===DONE===
--EXPECTF--
Test
http://example.com/?param=has%20spaces&foo=bar
===DONE===
PK R]Ð×3 3 tests/client003.phptnu [ --TEST--
client once & wait
--SKIPIF--
--FILE--
enqueue($request);
while ($client->once()) {
$client->wait(.1);
}
if (!$client->getResponse()) {
var_dump($client);
}
}
});
?>
Done
--EXPECT--
Test
Done
PK R]KS S tests/client006.phptnu [ --TEST--
client response callback + dequeue
--SKIPIF--
--FILE--
enqueue($request, "response");
$client->send();
try {
$client->dequeue($request);
} catch (Exception $e) {
echo $e->getMessage(),"\n";
}
}
}
});
?>
Done
--EXPECTREGEX--
Test
(?:(?:R
Failed to dequeue request; request not in queue
)+)+Done
PK R]Z,1< < , tests/data/message_rr_helloworld_chunked.txtnu [ GET /cgi-bin/chunked.sh HTTP/1.1
Host: localhost
Connection: close
HTTP/1.1 200 OK
Date: Thu, 26 Aug 2010 12:51:28 GMT
Server: Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0a mod_fastcgi/2.4.6
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain
5
Hello
2
,
7
World!
0
PK R]XB &