| Current File : /home/mmdealscpanel/yummmdeals.com/alt-php81-pecl-http_4.2.6-4.el8.zip |
PK 1 ["lI�a a tests/message010.phptnu �[��� --TEST--
message body
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$m = new http\Message;
$body = new http\Message\Body;
$body->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 1 [�/m�� � tests/client023.phptnu �[��� --TEST--
client available options and configuration
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
echo "Test\n";
$client = new http\Client;
if (($opt = $client->getOptions())) {
var_dump($options);
}
$client->setOptions($avail = $client->getAvailableOptions());
$opt = $client->getOptions();
foreach ($avail as $k => $v) {
if (is_array($v)) {
$oo = $opt[$k];
foreach ($v as $kk => $vv) {
if (isset($vv) && $oo[$kk] !== $vv) {
var_dump(array($kk => array($vv, $oo[$kk])));
}
}
} else if (isset($v) && $opt[$k] !== $v) {
var_dump(array($k => array($v, $opt[$k])));
}
}
var_dump($client === $client->configure($client->getAvailableConfiguration()));
?>
===DONE===
--EXPECT--
Test
bool(true)
===DONE===
PK 1 [.u�F F tests/url004.phptnu �[��� --TEST--
url as string
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$u = "http://user:pass@www.example.com:8080/path/file.ext".
"?foo=bar&more[]=1&more[]=2#hash";
$url = new http\Url($u);
var_dump((string) $url == (string) new http\Url((string) $url));
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 1 [���� � tests/version001.phptnu �[��� --TEST--
version parse error
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
error_reporting(E_ALL);
$m = new http\Message;
try {
$m->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 1 [x�� � tests/header008.phptnu �[��� --TEST--
header params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$header = new http\Header("Cache-control", "public, must-revalidate, max-age=0");
var_dump(
array(
"public" => array("value" => true, "arguments" => array()),
"must-revalidate" => array("value" => true, "arguments" => array()),
"max-age" => array("value" => "0", "arguments" => array()),
) === $header->getParams()->params
);
?>
Done
--EXPECT--
Test
bool(true)
Done
PK 1 [���& & tests/info001.phptnu �[��� --TEST--
invalid HTTP info
--SKIPIF--
<?php include "skipif.inc"; ?>
--INI--
zend.exception_ignore_args=off
--FILE--
<?php
try {
var_dump(new http\Message("GET HTTP/1.1"));
} catch (Exception $e) {
echo $e, "\n";
}
try {
var_dump(new http\Message("GET HTTP/1.123"));
} catch (Exception $e) {
echo $e, "\n";
}
try {
var_dump(new http\Message("GETHTTP/1.1"));
} catch (Exception $e) {
echo $e, "\n";
}
var_dump(new http\Message("GET / HTTP/1.1"));
?>
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 1 [l�Y� tests/cookie006.phptnu �[��� --TEST--
cookies expire
--SKIPIF--
<?php
include "skipif.inc";
?>
--INI--
date.timezone=UTC
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("this=expires; expires=Tue, 24 Jan 2012 10:35:32 +0100");
var_dump($c->getCookie("this"));
var_dump($c->getExpires());
$o = clone $c;
$t = time();
$o->setExpires();
var_dump(-1 === $o->getExpires());
var_dump(-1 != $c->getExpires());
$o->setExpires($t);
var_dump($t === $o->getExpires());
var_dump($t != $c->getExpires());
var_dump(
sprintf(
"this=expires; expires=%s; ",
date_create("@$t")
->setTimezone(new DateTimezone("UTC"))
->format("D, d M Y H:i:s \\G\\M\\T")
) === $o->toString()
);
?>
DONE
--EXPECT--
Test
string(7) "expires"
int(1327397732)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
DONE
PK 1 [�K��S S tests/client006.phptnu �[��� --TEST--
client response callback + dequeue
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
function response($response) {
echo "R\n";
if (!($response instanceof http\Client\Response)) {
var_dump($response);
}
/* automatically dequeue */
return true;
}
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
--EXPECTREGEX--
Test
(?:(?:R
Failed to dequeue request; request not in queue
)+)+Done
PK 1 [{��� � tests/urlparser007.phptnu �[��� --TEST--
url parser multibyte/utf-8/idna
--SKIPIF--
<?php
include "skipif.inc";
if (!defined("http\\Url::PARSE_TOIDN_2003")) {
die("skip need http\\Url::PARSE_TOIDN_2003 support");
}
?>
--FILE--
<?php
echo "Test\n";
$urls = array(
"s\xc3\xa7heme:",
"s\xc3\xa7heme://h\xc6\x9fst",
"s\xc3\xa7heme://h\xc6\x9fst:23/päth/öf/fıle"
);
foreach ($urls as $url) {
printf("\n%s\n", $url);
var_dump(new http\Url($url, null, http\Url::PARSE_MBUTF8|http\Url::PARSE_TOIDN_2003));
}
?>
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 1 [ * * tests/client019.phptnu �[��� --TEST--
client proxy - send proxy headers for a proxy request
--SKIPIF--
<?php
include "skipif.inc";
skip_online_test();
skip_client_test();
$client = new http\Client("curl");
array_key_exists("proxyheader", $client->getAvailableOptions())
or die("skip need libcurl with CURLOPT_PROXYHEADER support\n");
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
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://www.example.com/");
$r->setOptions(array(
"timeout" => 10,
"proxytunnel" => true,
"proxyheader" => array("Hello" => "there!"),
"proxyhost" => "localhost",
"proxyport" => $port,
));
try {
$c->enqueue($r)->send();
} catch (Exception $e) {
echo $e;
}
echo $c->getResponse()->getBody();
});
?>
===DONE===
--EXPECTF--
Test
Server on port %d
CONNECT www.example.com:80 HTTP/1.1
Hello: there!
Host: www.example.com:80
%r(Proxy-Connection: Keep-Alive
)?%rUser-Agent: PECL_HTTP/%s PHP/%s libcurl/%s
===DONE===
PK 1 [�/�� � tests/params017.phptnu �[��� --TEST--
header params rfc5988
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$link = <<<EOF
Link: </TheBook/chapter2>;
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
</TheBook/chapter4>;
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) "</TheBook/chapter2>;rel="previous";title*=utf-8'de'letztes%20Kapitel,</TheBook/chapter4>;rel="next";title*=utf-8'de'n%C3%A4chstes%20Kapitel"
===DONE===
PK 1 [2yTr� � tests/client012.phptnu �[��� --TEST--
client ssl
--SKIPIF--
<?php
include "skipif.inc";
skip_online_test();
skip_client_test();
skip_curl_test("7.34.0");
if (0 === strpos(http\Client\Curl\Versions\CURL, "7.87.0")) {
die("skip SSL bug in libcurl-7.87\n");
}
if (strpos(http\Client\Curl\Versions\SSL, "SecureTransport") !== false)
die("skip SecureTransport\n");
?>
--FILE--
<?php
echo "Test\n";
$client = new http\Client;
$client->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 1 [�|�=� � tests/messagebody002.phptnu �[��� --TEST--
message body append
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$temp = new http\Message\Body();
$temp->append("yes");
var_dump((string) $temp);
?>
DONE
--EXPECT--
Test
string(3) "yes"
DONE
PK 1 [bd��e e tests/urlparser002.phptnu �[��� --TEST--
url parser with paths
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$urls = array(
"s:a/",
"ss:aa/",
"s:/a/",
"ss:/aa/",
"s://a/",
"s://h/a",
"ss://hh/aa",
"s:///a/b",
"ss:///aa/bb",
);
foreach ($urls as $url) {
printf("\n%s\n", $url);
var_dump(new http\Url($url, null, 0));
}
?>
DONE
--EXPECTF--
Test
s:a/
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(2) "a/"
["query"]=>
NULL
["fragment"]=>
NULL
}
ss:aa/
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(3) "aa/"
["query"]=>
NULL
["fragment"]=>
NULL
}
s:/a/
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(3) "/a/"
["query"]=>
NULL
["fragment"]=>
NULL
}
ss:/aa/
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(4) "/aa/"
["query"]=>
NULL
["fragment"]=>
NULL
}
s://a/
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "a"
["port"]=>
NULL
["path"]=>
string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
s://h/a
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "h"
["port"]=>
NULL
["path"]=>
string(2) "/a"
["query"]=>
NULL
["fragment"]=>
NULL
}
ss://hh/aa
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(2) "hh"
["port"]=>
NULL
["path"]=>
string(3) "/aa"
["query"]=>
NULL
["fragment"]=>
NULL
}
s:///a/b
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(4) "/a/b"
["query"]=>
NULL
["fragment"]=>
NULL
}
ss:///aa/bb
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(6) "/aa/bb"
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK 1 [�߆�! ! tests/params012.phptnu �[��� --TEST--
no args params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params;
$p["param"] = true;
var_dump("param" === $p->toString());
$p["param"] = false;
var_dump("param=0" === $p->toString());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK 1 [���
�
tests/client029.phptnu �[��� --TEST--
client curl user handler
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
_ext("event");
?>
--FILE--
<?php
echo "Test\n";
class UserHandler implements http\Client\Curl\User
{
private $evbase;
private $client;
private $run;
private $ios = [];
private $timeout;
function __construct(http\Client $client, EventBase $evbase) {
$this->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 1 [���i6 6 tests/client005.phptnu �[��� --TEST--
client response callback
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
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
--EXPECTREGEX--
Test
(?:R
)+Done
PK 1 [����0 0 tests/client004.phptnu �[��� --TEST--
client reset
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
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);
}
});
?>
Done
--EXPECTREGEX--
Test
(?:Failed to enqueue request; request already in queue
)+Done
PK 1 [iM��< < tests/cookie005.phptnu �[��� --TEST--
cookies simple data
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$orig = new http\Cookie("key=value");
$copy = clone $orig;
$same = new http\Cookie($copy);
$even = new http\Cookie($same->toArray());
foreach (array($orig, $copy) as $c) {
var_dump($c->getCookie("key"));
var_dump($c->getExpires());
var_dump($c->getMaxAge());
var_dump($c->getFlags());
var_dump($c->getPath());
var_dump($c->getDomain());
var_dump($c->getExtras());
var_dump($c->getCookies());
var_dump($c->toString());
var_dump(
array (
"cookies" =>
array (
"key" => "value",
),
"extras" =>
array (
),
"flags" => 0,
"expires" => -1,
"path" => "",
"domain" => "",
"max-age" => -1,
) == $c->toArray()
);
}
?>
DONE
--EXPECT--
Test
string(5) "value"
int(-1)
int(-1)
int(0)
NULL
NULL
array(0) {
}
array(1) {
["key"]=>
string(5) "value"
}
string(11) "key=value; "
bool(true)
string(5) "value"
int(-1)
int(-1)
int(0)
NULL
NULL
array(0) {
}
array(1) {
["key"]=>
string(5) "value"
}
string(11) "key=value; "
bool(true)
DONE
PK 1 [釃)� � tests/cookie010.phptnu �[��� --TEST--
cookies flags
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("icanhas=flags; secure; httpOnly");
var_dump(http\Cookie::SECURE === ($c->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 1 [���B B tests/params007.phptnu �[��� --TEST--
urlencoded params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$s = "foo=b%22r&bar=b%22z&a%5B%5D%5B%5D=1";
$p = new http\Params($s, "&", "", "=", http\Params::PARSE_URLENCODED);
$c = array(
"foo" => 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 1 [Ծ�~ ~ tests/bug61444.phptnu �[��� --TEST--
Bug #61444 (. become _ in query strings due to php_default_treat_data())
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
$url = 'http://www.example.com/foobar?bar.baz=blah&utm_source=google&utm_campaign=somethingelse&blat';
// Original
echo $url, PHP_EOL, PHP_EOL;
// Changing a parameter in the string
echo new http\Url($url, array('query' => '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 1 [8㸒� � tests/header009.phptnu �[��� --TEST--
header params w/ args
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$header = new http\Header("Custom", '"foo" is "bar". "bar" is "bis" where "bis" is "where".');
var_dump(
array(
"foo" => 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 1 [�H�� � tests/client020.phptnu �[��� --TEST--
client proxy - don't send proxy headers for a standard request
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
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/");
$r->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 1 [$
̩7 7 tests/cookie002.phptnu �[��� --TEST--
cookies expire as date
--SKIPIF--
<?php
include "skipif.inc";
?>
--INI--
date.timezone=UTC
--FILE--
<?php
echo "Test\n";
$d = new DateTime;
$c = new http\Cookie(array("expires" => $d->format(DateTime::RFC1123)));
var_dump($d->format("U") == $c->getExpires());
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 1 [����Q Q tests/client026.phptnu �[��� --TEST--
client stream 128M
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
include "helper/dump.inc";
echo "Test\n";
server("proxy.inc", function($port) {
$client = new http\Client;
$request = new http\Client\Request("PUT", "http://localhost:$port");
$request->setContentType("application/octet-stream");
for ($i = 0, $data = str_repeat("a",1024); $i < 128*1024; ++$i) {
$request->getBody()->append($data);
}
$request->setOptions(array("timeout" => 10, "expect_100_timeout" => 0));
$client->enqueue($request);
$client->send();
dump_headers(null, $client->getResponse()->getHeaders());
});
?>
===DONE===
--EXPECTF--
Test
Accept-Ranges: bytes
Content-Length: %d
Etag: "%x"
Last-Modified: %s
X-Original-Transfer-Encoding: chunked
X-Request-Content-Length: 134217728
===DONE===
PK 1 [�F�� � tests/headerparser001.phptnu �[��� --TEST--
header parser
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$headers = array(
"One: ","header\n",
"Two: header\n\tlines\n",
"Three",": header\n lines\n here\n",
"More: than one header\n",
"More: ", "than: ", "you: ", "expect\n",
"\n",
);
$states = array(-1=>"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 1 [�D�o o tests/clientresponse003.phptnu �[��� --TEST--
client response transfer info
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
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);
$response = $client->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 1 [�G�� tests/querystring003.phptnu �[��� --TEST--
querystring offset set
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$qs = new http\QueryString("foo=bar&bar=baz");
echo $qs,"\n";
$qs["foo"] = "baz";
echo $qs,"\n";
?>
===DONE===
--EXPECT--
Test
foo=bar&bar=baz
bar=baz&foo=baz
===DONE===
PK 1 ["���` ` tests/urlparser005.phptnu �[��� --TEST--
url parser multibyte/utf-8
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$urls = array(
"s\xc3\xa7heme:",
"s\xc3\xa7heme://h\xc6\x9fst",
"s\xc3\xa7heme://h\xc6\x9fst:23/päth/öf/fıle"
);
foreach ($urls as $url) {
printf("\n%s\n", $url);
var_dump(new http\Url($url, null, http\Url::PARSE_MBUTF8));
}
?>
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 1 [��F� � tests/client022.phptnu �[��� --TEST--
client http2
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
skip_http2_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
nghttpd(function($port) {
$client = new http\Client;
$client->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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HTTP2</title>
</head>
<body>
Nothing to see here.
</body>
</html>
===DONE===
PK 1 [!>�� � tests/header006.phptnu �[��� --TEST--
header parsing
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$header = "Foo: bar\nBar: foo\n";
var_dump(array("Foo"=>"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 1 [��� � tests/bug73055.phptnu �[��� --TEST--
Bug #73055 (Type confusion vulnerability in merge_param())
--SKIPIF--
<?php
include "skipif.inc";
?>
--INI--
zend.exception_ignore_args=off
--FILE--
<?php
echo "Test\n";
try {
echo new http\QueryString("[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]][[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[&%C0[]E[=&2[&%C0[]E[16706[*[");
} catch (Exception $e) {
echo $e;
}
?>
===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 1 [���=R R tests/params010.phptnu �[��� --TEST--
int key params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params("0=nothing;1=yes");
var_dump(array("0" => array("value" => "nothing", "arguments" => array(1=>"yes"))) === $p->params);
var_dump("0=nothing;1=yes" === $p->toString());
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK 1 [��M�� � tests/params006.phptnu �[��� --TEST--
escaped params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params("form-data; name=\"upload\"; filename=\"trick\\\"\0\\\"ed\"");
$c = array(
"form-data" => array(
"value" => true,
"arguments" => array(
"name" => "upload",
"filename" => "trick\"\0\"ed"
)
)
);
var_dump($c === $p->params);
var_dump("form-data;name=upload;filename=\"trick\\\"\\000\\\"ed\"" === (string) $p);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK 2 [��� � tests/cookie003.phptnu �[��� --TEST--
cookies numeric keys
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("1=%20; 2=%22; 3=%5D", 0, array(2));
var_dump("1=%20; 3=%5D; 2=%22; " === (string) $c);
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 2 [b�N� � tests/urlparser001.phptnu �[��� --TEST--
url parser
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$urls = array(
"s:",
"ss:",
"s:a",
"ss:aa",
"s://",
"ss://",
"s://a",
"ss://aa",
);
foreach ($urls as $url) {
printf("\n%s\n", $url);
var_dump(new http\Url($url, null, 0));
}
?>
DONE
--EXPECTF--
Test
s:
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
ss:
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s:a
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(1) "a"
["query"]=>
NULL
["fragment"]=>
NULL
}
ss:aa
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
string(2) "aa"
["query"]=>
NULL
["fragment"]=>
NULL
}
s://
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
ss://
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
NULL
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
s://a
object(http\Url)#%d (8) {
["scheme"]=>
string(1) "s"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(1) "a"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
ss://aa
object(http\Url)#%d (8) {
["scheme"]=>
string(2) "ss"
["user"]=>
NULL
["pass"]=>
NULL
["host"]=>
string(2) "aa"
["port"]=>
NULL
["path"]=>
NULL
["query"]=>
NULL
["fragment"]=>
NULL
}
DONE
PK 2 [���o� � tests/params015.phptnu �[��� --TEST--
header params rfc5987 regression
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params(array("attachment"=>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 2 [�*�� tests/params001.phptnu �[��� --TEST--
header params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$ct = new http\Params("text/html; charset=utf-8", ",", ";", "=", 0);
var_dump(
isset($ct["text/html"]),
isset($ct["text/json"]),
$ct["text/html"]["arguments"]["charset"]
);
unset($ct["text/html"]);
$ct[] = "text/json";
$ct["text/json"] = array("arguments" => array("charset" => "iso-8859-1"));
var_dump(
isset($ct["text/html"]),
isset($ct["text/json"]),
$ct["text/json"]["arguments"]["charset"]
);
var_dump((string) $ct,$ct);
?>
DONE
--EXPECTF--
Test
bool(true)
bool(false)
string(5) "utf-8"
bool(false)
bool(true)
string(10) "iso-8859-1"
string(%d) "text/json;charset=iso-8859-1"
object(http\Params)#%d (5) {
["params"]=>
array(1) {
["text/json"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["charset"]=>
string(10) "iso-8859-1"
}
}
}
["param_sep"]=>
string(1) ","
["arg_sep"]=>
string(1) ";"
["val_sep"]=>
string(1) "="
["flags"]=>
int(0)
}
DONE
PK 2 [`@B& tests/clientrequest003.phptnu �[��� --TEST--
client request query
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$r = new http\Client\Request("GET", "http://localhost/");
var_dump(null === $r->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 2 [ωZ= = tests/messagebody008.phptnu �[��� --TEST--
message body to callback
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$file = new http\Message\Body(fopen(__FILE__,"r"));
$s = "";
$file->toCallback(
function($body, $string) use (&$s) { $s.=$string; }
);
var_dump($s === (string) $file);
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 2 [��fP5 5 tests/params016.phptnu �[��� --TEST--
header params rfc5988
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$link = <<<EOF
<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2>; rel="next", <https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>; rel="last"
EOF;
$p = new http\Params($link, ",", ";", "=",
http\Params::PARSE_RFC5988 | http\Params::PARSE_ESCAPED);
var_dump($p->params);
var_dump((string)$p);
?>
===DONE===
--EXPECT--
Test
array(2) {
["https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["rel"]=>
string(4) "next"
}
}
["https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34"]=>
array(2) {
["value"]=>
bool(true)
["arguments"]=>
array(1) {
["rel"]=>
string(4) "last"
}
}
}
string(162) "<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=2>;rel="next",<https://api.github.com/search/code?q=addClass+user%3Amozilla&page=34>;rel="last""
===DONE===
PK 2 [%w�c- - tests/url002.phptnu �[��� --TEST--
url properties
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$u = "http://user:pass@www.example.com:8080/path/file.ext".
"?foo=bar&more[]=1&more[]=2#hash";
var_dump($u === (string) new http\Url($u));
$url = new http\Url($u,
array("path" => "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 2 [0��Y� � tests/url003.phptnu �[��� --TEST--
url modification
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$u = "http://user:pass@www.example.com:8080/path/file.ext".
"?foo=bar&more[]=1&more[]=2#hash";
$tmp = new http\Url($u);
$mod = $tmp->mod(array("query" => "set=1"), http\Url::REPLACE);
var_dump($tmp->toArray() != $mod->toArray());
var_dump("set=1" === $mod->query);
var_dump("new_fragment" === $tmp->mod("#new_fragment")->fragment);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
DONE
PK 2 [��p}6 6 tests/client001.phptnu �[��� --TEST--
client drivers
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
echo "Test\n";
foreach (http\Client::getAvailableDrivers() as $driver) {
$client = new http\Client($driver);
var_dump($client instanceof http\Client);
}
?>
Done
--EXPECTREGEX--
Test
(?:bool\(true\)
)+Done
PK 2 [�n� tests/bug69000.phptnu �[��� --TEST--
Bug #69000 (http\Url breaks down with very long URL query strings)
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
echo new http\Url("http://foo.bar/?".str_repeat("a", 1024));
?>
===DONE===
--EXPECT--
Test
http://foo.bar/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
===DONE===
PK 2 [)��3 3 tests/params003.phptnu �[��� --TEST--
default params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$s = "foo, bar;arg=0;bla, gotit=0;now";
$p = new http\Params($s);
$c = str_replace(" ", "", $s);
$k = array("foo", "bar", "gotit");
$a = array("foo"=>"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 2 [����1 1 tests/header007.phptnu �[��� --TEST--
header parse error
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$header = "wass\nup";
http\Header::parse($header);
?>
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 2 [�l�+# # tests/bug67932.phptnu �[��� --TEST--
Bug #67932 (php://input always empty)
--SKIPIF--
<?php
include "skipif.inc";
?>
--PUT--
Content-Type: text/xml
<?xml version="1.0" encoding="utf-8" ?>
<body>test</body>
--FILE--
<?php
readfile("php://input");
?>
--EXPECT--
<?xml version="1.0" encoding="utf-8" ?>
<body>test</body>PK 2 [7�7 7 tests/serialize001.phptnu �[��� --TEST--
serialization
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
$ext = new ReflectionExtension("http");
foreach ($ext->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 2 [��_�N N tests/clientrequest002.phptnu �[��� --TEST--
client request content type
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$r = new http\Client\Request("POST", "http://localhost/");
var_dump($r === $r->setContentType($ct = "text/plain; charset=utf-8"));
var_dump($ct === $r->getContentType());
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
Done
PK 2 [l.�Q� � tests/params014.phptnu �[��� --TEST--
header params rfc5987
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$u = urlencode("ü");
$s = urlencode("ß");
$t = "p1*=utf-8''s$u$s,p2*=utf-8''hei$s;a1*=utf-8''a$s;a2*=utf-8''e$s;a3=no,p3=not";
$p = new http\Params($t);
var_dump($p->params);
var_dump((string)$p === $t, (string)$p, $t);
?>
===DONE===
--EXPECT--
Test
array(3) {
["p1"]=>
array(2) {
["*rfc5987*"]=>
array(1) {
[""]=>
string(5) "süß"
}
["arguments"]=>
array(0) {
}
}
["p2"]=>
array(2) {
["*rfc5987*"]=>
array(1) {
[""]=>
string(5) "heiß"
}
["arguments"]=>
array(2) {
["*rfc5987*"]=>
array(2) {
["a1"]=>
array(1) {
[""]=>
string(3) "aß"
}
["a2"]=>
array(1) {
[""]=>
string(3) "eß"
}
}
["a3"]=>
string(2) "no"
}
}
["p3"]=>
array(2) {
["value"]=>
string(3) "not"
["arguments"]=>
array(0) {
}
}
}
bool(true)
string(96) "p1*=utf-8''s%C3%BC%C3%9F,p2*=utf-8''hei%C3%9F;a1*=utf-8''a%C3%9F;a2*=utf-8''e%C3%9F;a3=no,p3=not"
string(96) "p1*=utf-8''s%C3%BC%C3%9F,p2*=utf-8''hei%C3%9F;a1*=utf-8''a%C3%9F;a2*=utf-8''e%C3%9F;a3=no,p3=not"
===DONE===
PK 2 [ �U U tests/gh-issue11.phptnu �[��� --TEST--
crash when query string has nested array keys
--SKIPIF--
<?php
include "skipif.inc";
version_compare(PHP_VERSION, "7.0.0-dev") or die("skip php<7");
?>
--FILE--
<?php
echo "Test\n";
$q = new http\QueryString("a[0][0]=x&a[1][0]=x");
printf("%s\n", $q);
?>
===DONE===
--EXPECT--
Test
a%5B0%5D%5B0%5D=x&a%5B1%5D%5B0%5D=x
===DONE===
PK 2 ["�Ga� � tests/params013.phptnu �[��� --TEST--
header params rfc5987
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params("attachment; filename*=IsO-8859-1''d%f6ner.pdf");
var_dump($p->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 2 [nYt�� � tests/messagebody005.phptnu �[��� --TEST--
message body add part
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$temp = new http\Message\Body;
var_dump($temp->getBoundary());
$temp->addPart(new http\Message("This: is a header\n\nand this is the data\n"));
var_dump($temp->getBoundary());
echo $temp;
?>
DONE
--EXPECTF--
Test
NULL
string(%d) "%x.%x"
--%x.%x
This: is a header
Content-Length: 21
and this is the data
--%x.%x--
DONE
PK 2 [)�� tests/client024.phptnu �[��� --TEST--
client deprecated methods
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
if (!(error_reporting() & E_DEPRECATED))
die("skip error_reporting() & ~E_DEPRECATED\n");
?>
--FILE--
<?php
echo "Test\n";
$client = new http\Client;
$client->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 2 [���6K K tests/filterchunked.phptnu �[��� --TEST--
chunked filter
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
list($in, $out) = stream_socket_pair(
STREAM_PF_UNIX,
STREAM_SOCK_STREAM,
STREAM_IPPROTO_IP
);
stream_filter_append($in, "http.chunked_decode", STREAM_FILTER_READ);
stream_filter_append($out, "http.chunked_encode", STREAM_FILTER_WRITE,
array());
$file = file(__FILE__);
foreach($file as $line) {
fwrite($out, $line);
fflush($out);
}
fclose($out);
if (implode("",$file) !== ($read = fread($in, filesize(__FILE__)))) {
echo "got: $read\n";
}
fclose($in);
?>
DONE
--EXPECT--
DONE
PK 2 [0ܙ�� � tests/clientresponse002.phptnu �[��� --TEST--
client response cookies
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
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--
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 3 [N���� � tests/message009.phptnu �[��� --TEST--
message properties
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
class message extends http\Message {
function __call($m, $args) {
if (preg_match("/^test(get|set)(.*)\$/i", $m, $match)) {
list(, $getset, $prop) = $match;
$prop = strtolower($prop[0]).substr($prop,1);
switch(strtolower($getset)) {
case "get":
return $this->$prop;
case "set":
$this->$prop = current($args);
break;
}
}
}
}
$test = new message;
var_dump(0 === $test->testGetType());
var_dump(null === $test->testGetBody());
var_dump(null === $test->testGetRequestMethod());
var_dump(null === $test->testGetRequestUrl());
var_dump(null === $test->testGetResponseStatus());
var_dump(null === $test->testGetResponseCode());
var_dump("1.1" === $test->testGetHttpVersion());
var_dump(array() === $test->testGetHeaders());
var_dump(null === $test->testGetParentMessage());
$test->testSetType(http\Message::TYPE_REQUEST);
var_dump(http\Message::TYPE_REQUEST === $test->testGetType());
var_dump(http\Message::TYPE_REQUEST === $test->getType());
$body = new http\Message\Body;
$test->testSetBody($body);
var_dump($body === $test->testGetBody());
var_dump($body === $test->getBody());
$file = fopen(__FILE__,"r");
$test->testSetBody($file);
var_dump($file === $test->testGetBody()->getResource());
var_dump($file === $test->getBody()->getResource());
$test->testSetBody("data");
var_dump("data" === (string) $test->testGetBody());
var_dump("data" === (string) $test->getBody());
$test->testSetRequestMethod("HEAD");
var_dump("HEAD" === $test->testGetRequestMethod());
var_dump("HEAD" === $test->getRequestMethod());
$test->testSetRequestUrl("/");
var_dump("/" === $test->testGetRequestUrl());
var_dump("/" === $test->getRequestUrl());
var_dump("HEAD / HTTP/1.1" === $test->getInfo());
$test->testSetType(http\Message::TYPE_RESPONSE);
$test->setResponseStatus("Created");
var_dump("Created" === $test->testGetResponseStatus());
var_dump("Created" === $test->getResponseStatus());
$test->setResponseCode(201);
var_dump(201 === $test->testGetResponseCode());
var_dump(201 === $test->getResponseCode());
$test->testSetResponseStatus("Ok");
var_dump("Ok" === $test->testGetResponseStatus());
var_dump("Ok" === $test->getResponseStatus());
$test->testSetResponseCode(200);
var_dump(200 === $test->testGetResponseCode());
var_dump(200 === $test->getResponseCode());
$test->testSetHttpVersion("1.0");
var_dump("1.0" === $test->testGetHttpVersion());
var_dump("1.0" === $test->getHttpVersion());
var_dump("HTTP/1.0 200 OK" === $test->getInfo());
$test->setHttpVersion("1.1");
var_dump("1.1" === $test->testGetHttpVersion());
var_dump("1.1" === $test->getHttpVersion());
var_dump("HTTP/1.1 200 OK" === $test->getInfo());
$test->setInfo("HTTP/1.1 201 Created");
var_dump("Created" === $test->testGetResponseStatus());
var_dump("Created" === $test->getResponseStatus());
var_dump(201 === $test->testGetResponseCode());
var_dump(201 === $test->getResponseCode());
var_dump("1.1" === $test->testGetHttpVersion());
var_dump("1.1" === $test->getHttpVersion());
$test->testSetHeaders(array("Foo" => "bar"));
var_dump(array("Foo" => "bar") === $test->testGetHeaders());
var_dump(array("Foo" => "bar") === $test->getHeaders());
var_dump("bar" === $test->getHeader("foo"));
var_dump(false === $test->getHeader("bar"));
$parent = new message;
$test->testSetParentMessage($parent);
var_dump($parent === $test->testGetParentMessage());
var_dump($parent === $test->getParentMessage());
?>
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)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Done
PK 3 [.�%� � tests/client002.phptnu �[��� --TEST--
client observer
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
class Observer implements SplObserver
{
#[ReturnTypeWillChange]
function update(SplSubject $client, ?http\Client\Request $request = null, ?StdClass $progress = null) {
echo "P";
/* fence against buggy infof() calls in some curl versions */
$compare = $client->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 3 [ɤ|̟ � tests/client031.phptnu �[��� --TEST--
client cookie sharing disabled
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
include "helper/dump.inc";
echo "Test\n";
server("cookie.inc", function($port) {
$client = new http\Client(null, "cookies");
$client->configure(array("share_cookies" => false));
$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 = 0; $i < 3; ++$i) {
/* new requests */
$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]);
});
?>
===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=1;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=1;
X-Original-Transfer-Encoding: chunked
Etag: ""
Set-Cookie: counter=2;
X-Original-Transfer-Encoding: chunked
===DONE===
PK 3 [G�v^ tests/cookie004.phptnu �[��� --TEST--
cookies raw
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("1=%20; 2=%22; e3=%5D", http\Cookie::PARSE_RAW, array(2));
var_dump("1=%2520; e3=%255D; 2=%2522; " === (string) $c);
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 3 [-1�$� � tests/skipif.incnu �[��� <?php
_ext("http");
function _ext($ext) {
if (!extension_loaded($ext)) {
die("skip $ext extension needed\n");
}
}
function utf8locale() {
$locale = setlocale(LC_CTYPE, null);
if (stristr($locale, "utf") && substr($locale, -1) === "8") {
return true;
}
if (stristr(setlocale(LC_CTYPE, "C.UTF-8"), "utf")) {
return true;
}
$locale = setlocale(LC_CTYPE, null);
if (stristr($locale, "utf") && substr($locale, -1) === "8") {
return true;
}
return false;
}
function skip_online_test($message = "skip test requiring internet connection\n") {
if (getenv("SKIP_ONLINE_TESTS")) {
die($message);
}
}
function skip_slow_test($message = "skip slow test\n") {
if (getenv("SKIP_SLOW_TESTS")) {
die($message);
}
}
function skip_client_test($message = "skip need a client driver\n") {
if (!http\Client::getAvailableDrivers()) {
die($message);
}
}
function skip_curl_test($version) {
if (!version_compare(http\Client\Curl\Versions\CURL, $version, ">=")) {
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 3 [mU*! ! tests/message014.phptnu �[��� --TEST--
message prepend
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
for ($i=0; $i<9; ++$i) {
$a[] = new http\Message("HTTP/1.1 ".($i+200));
}
foreach ($a as $m) {
if (isset($p)) $m->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 3 [�GU� � tests/params011.phptnu �[��� --TEST--
bool args params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params;
$container = array("value" => 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 3 [��kI I tests/bug69357.phptnu �[��� --TEST--
Bug #69357 (HTTP/1.1 100 Continue overriding subsequent 200 response code with PUT request)
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
echo "Test\n";
include "helper/server.inc";
server("upload.inc", function($port) {
$b = new \http\Message\Body;
$b->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 3 [� �W� � tests/client017.phptnu �[��� --TEST--
client request gzip
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/server.inc";
echo "Test\n";
server("env.inc", function($port) {
$request = new http\Client\Request("GET", "http://localhost:$port/");
$client = new http\Client;
$client->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 3 [�k� k k tests/cookie012.phptnu �[��� --TEST--
cookies cookies
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("e0=1; c1=v1; e2=2; c2=v2", 0, array("c0", "c1", "c2"));
var_dump(array("c1"=>"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 3 [�F̥� � tests/messageparser002.phptnu �[��� --TEST--
message parser with nonblocking stream
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$parser = new http\Message\Parser;
$socket = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
stream_set_blocking($socket[0], 0);
$message = array(
"GET / HTTP/1.1\n",
"Host: localhost\n",
"Content-length: 3\n",
"\n",
"OK\n"
);
while ($message) {
$line = array_shift($message);
$parser->stream($socket[0], 0, $msg);
fwrite($socket[1], $line);
$parser->stream($socket[0], 0, $msg);
}
var_dump($msg, (string) $msg->getBody());
?>
DONE
--EXPECTF--
Test
object(http\Message)#%d (9) {
["type":protected]=>
int(1)
["body":protected]=>
object(http\Message\Body)#%d (0) {
}
["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(3) {
["Host"]=>
string(9) "localhost"
["Content-Length"]=>
string(1) "3"
["X-Original-Content-Length"]=>
string(1) "3"
}
["parentMessage":protected]=>
NULL
}
string(3) "OK
"
DONE
PK 3 [�ꋽ tests/header005.phptnu �[��� --TEST--
header negotiation
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
function r($v) { return round($v, 2); }
$a = new http\Header("Accept", "text/html, text/plain;q=0.5, */*;q=0");
var_dump("text/html" === $a->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 3 [ss��� � tests/gh-issue50.phptnu �[��� --TEST--
segfault with Client::setDebug and Client::dequeue()
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
skip_online_test();
?>
--INI--
zend.exception_ignore_args=off
--FILE--
<?php
echo "Test\n";
$c = new http\Client;
$c->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 3 [�Y`�� � tests/messagebody003.phptnu �[��� --TEST--
message body append error
--SKIPIF--
<?php
include "skipif.inc";
?>
--INI--
zend.exception_ignore_args=off
--FILE--
<?php
echo "Test\n";
$file = new http\Message\Body(fopen(__FILE__, "r"));
try {
@$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 3 [v�3� � tests/header002.phptnu �[��� --TEST--
header numeric
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$h = new http\Header(123, 456);
var_dump("123: 456" === (string) $h);
?>
Done
--EXPECT--
Test
bool(true)
Done
PK 3 [��� � tests/params005.phptnu �[��� --TEST--
quoted params
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$p = new http\Params("multipart/form-data; boundary=\"--123\"");
$c = array(
"multipart/form-data" => array(
"value" => true,
"arguments" => array(
"boundary" => "--123"
)
)
);
var_dump($c === $p->params);
var_dump("multipart/form-data;boundary=--123" === (string) $p);
?>
DONE
--EXPECT--
Test
bool(true)
bool(true)
DONE
PK 3 [f9�F� � tests/etag001.phptnu �[��� --TEST--
etags with hash
--SKIPIF--
<?php
include "skipif.inc";
_ext("hash");
?>
--FILE--
<?php
$body = new http\Message\Body;
$body->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 3 [u���Z Z tests/url005.phptnu �[��� --TEST--
url as array
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$u = "http://user:pass@www.example.com:8080/path/file.ext".
"?foo=bar&more[]=1&more[]=2#hash";
$url = new http\Url($u);
$url2 = new http\Url($url->toArray());
var_dump($url->toArray() === $url2->toArray());
?>
DONE
--EXPECT--
Test
bool(true)
DONE
PK 3 [�� �� � tests/filterbrotli.phptnu �[��� --TEST--
brotli filter
--SKIPIF--
<?php
include "skipif.inc";
class_exists("http\\Encoding\\Stream\\Enbrotli", false) or die("SKIP need brotli support");
?>
--FILE--
<?php
list($in, $out) = stream_socket_pair(
STREAM_PF_UNIX,
STREAM_SOCK_STREAM,
STREAM_IPPROTO_IP
);
stream_filter_append($in, "http.brotli_decode", STREAM_FILTER_READ);
stream_filter_append($out, "http.brotli_encode", STREAM_FILTER_WRITE,
http\Encoding\Stream\Enbrotli::LEVEL_MAX);
$file = file(__FILE__);
foreach ($file as $line) {
fwrite($out, $line);
fflush($out);
}
fclose($out);
if (implode("",$file) !== ($read = fread($in, filesize(__FILE__)))) {
echo "got: $read\n";
}
fclose($in);
?>
DONE
--EXPECT--
DONE
PK 3 [
fY?� � tests/message004.phptnu �[��� --TEST--
message reversal
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
use http\Message as HttpMessage;
function newHttpMessage($s) {
return new http\Message($s);
}
$s = "GET /first HTTP/1.1\nHTTP/1.1 200 Ok-first\nGET /second HTTP/1.1\nHTTP/1.1 200 Ok-second\nGET /third HTTP/1.1\nHTTP/1.1 200 Ok-third\n";
echo newHttpMessage($s)->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 3 [[�.�� � tests/clientrequest001.phptnu �[��� --TEST--
client request
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$r = new http\Client\Request(
$m = "POST",
$u = "http://localhost/foo",
$h = array("header", "value"),
$b = new http\Message\Body(fopen(__FILE__, "r+b"))
);
var_dump($b === $r->getBody());
var_dump($h === $r->getHeaders());
var_dump($u === $r->getRequestUrl());
var_dump($m === $r->getRequestMethod());
?>
Done
--EXPECT--
Test
bool(true)
bool(true)
bool(true)
bool(true)
Done
PK 3 [��KH] ] tests/bug69313.phptnu �[��� --TEST--
Bug #69313 (http\Client doesn't send GET body)
--SKIPIF--
<?php
include "skipif.inc";
skip_client_test();
?>
--FILE--
<?php
include "helper/dump.inc";
include "helper/server.inc";
echo "Test\n";
server("proxy.inc", function($port, $stdin, $stdout, $stderr) {
$request = new http\Client\Request("GET", "http://localhost:$port/");
$request->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 4 [�� tests/urlparser006.phptnu �[��� --TEST--
url parser multibyte/locale/idna
--SKIPIF--
<?php
include "skipif.inc";
if (!defined("http\\Url::PARSE_MBLOC") or
!defined("http\\Url::PARSE_TOIDN_2003") or
!utf8locale()) {
die("skip need http\\Url::PARSE_MBLOC|http\\Url::PARSE_TOIDN_2003 support and LC_CTYPE=*.UTF-8");
}
?>
--FILE--
<?php
echo "Test\n";
include "skipif.inc";
utf8locale();
$urls = array(
"s\xc3\xa7heme:",
"s\xc3\xa7heme://h\xc6\x9fst",
"s\xc3\xa7heme://h\xc6\x9fst:23/päth/öf/fıle"
);
foreach ($urls as $url) {
printf("\n%s\n", $url);
var_dump(new http\Url($url, null, http\Url::PARSE_MBLOC|http\Url::PARSE_TOIDN_2003));
}
?>
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 4 [^ ~}m m tests/messagebody010.phptnu �[��� --TEST--
message body resource
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$file = new http\Message\Body(fopen(__FILE__,"r"));
for($i=0;$i<10;++$i) $stream = $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 4 [�i| | tests/cookie008.phptnu �[��� --TEST--
cookies path
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
echo "Test\n";
$c = new http\Cookie("this=has a path; path=/down; ");
var_dump($c->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 4 [�`�/
/
tests/message003.phptnu �[��� --TEST--
multipart message
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
$m = new http\Message(fopen(__DIR__."/data/message_r_multipart_put.txt","rb"));
if ($m->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 <mike@iworks.at>.
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 4 [V�
� � &