if (Z_TYPE(opt->defval) == IS_STRING && !Z_STRVAL(opt->defval)) {
ZVAL_NULL(entry);
} else {
- ZVAL_ZVAL(entry, &opt->defval, 1, 0);
+ ZVAL_COPY_VALUE(entry, &opt->defval);
+ zval_copy_ctor(entry);
}
}
return SUCCESS;
}
+static inline zend_function *get_object_method(zval *zobject, zval *zmeth TSRMLS_DC)
+{
+#if PHP_VERSION_ID >= 50400
+ return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth), NULL TSRMLS_CC);
+#else
+ return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth) TSRMLS_CC);
+#endif
+}
+
php_http_object_method_t *php_http_object_method_init(php_http_object_method_t *cb, zval *zobject, const char *method_str, size_t method_len TSRMLS_DC)
{
zval *zfn;
cb->fci.function_name = zfn;
cb->fcc.initialized = 1;
cb->fcc.calling_scope = cb->fcc.called_scope = Z_OBJCE_P(zobject);
- cb->fcc.function_handler = Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(cb->fci.function_name), Z_STRLEN_P(cb->fci.function_name), NULL TSRMLS_CC);
+ cb->fcc.function_handler = get_object_method(zobject, cb->fci.function_name TSRMLS_CC);
return cb;
}
if (cb->fcc.called_scope != Z_OBJCE_P(zobject)) {
cb->fcc.called_scope = Z_OBJCE_P(zobject);
- cb->fcc.function_handler = Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(cb->fci.function_name), Z_STRLEN_P(cb->fci.function_name), NULL TSRMLS_CC);
+ cb->fcc.function_handler = get_object_method(zobject, cb->fci.function_name TSRMLS_CC);
}
rv = zend_call_function(&cb->fci, &cb->fcc TSRMLS_CC);
$r = new http\Env\Response;
$r->setResponseCode(200);
$r->send();
-var_dump(http_response_code());
+var_dump(http\Env::getResponseCode());
?>
--EXPECT--
int(200)
\ No newline at end of file
$request = new http\Client\Request("GET", "http://localhost:$port");
$client = new http\Client();
- $client->configure(["pipelining" => true, "use_eventloop" => true]);
+ $client->configure(array("pipelining" => true, "use_eventloop" => true));
$client->enqueue($request);
$client->send();
$client1 = new http\Client;
$client2 = new http\Client;
- $client1->configure(["use_eventloop" => true]);
- $client2->configure(["use_eventloop" => true]);
+ $client1->configure(array("use_eventloop" => true));
+ $client2->configure(array("use_eventloop" => true));
$client1->enqueue(new http\Client\Request("GET", "http://localhost:$port/"));
$client2->enqueue(new http\Client\Request("GET", "http://localhost:$port/"));
foreach (http\Client::getAvailableDrivers() as $driver) {
$client = new http\Client($driver);
- $client->configure(["use_eventloop" => true]);
+ $client->configure(array("use_eventloop" => true));
$client->enqueue($request);
while ($client->once()) {
echo "Test\n";
$client = new http\Client;
-$client->setOptions(["compress" => true]);
+$client->setOptions(array("compress" => true));
$client->enqueue(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.print_request.php"));
$client->send();
fputs($stdin, "3\n");
$client = new http\Client(null);
- $client->configure(["pipelining" => true, "max_host_connections" => 0]);
+ $client->configure(array("pipelining" => true, "max_host_connections" => 0));
/* this is just to let curl know the server may be capable of pipelining */
$client->enqueue(new http\Client\Request("GET", "http://localhost:$port"));
$tmpfile = tempnam(sys_get_temp_dir(), "cookie.");
$request = new http\Client\Request("GET", "http://localhost");
-$request->setOptions(["cookiestore" => $tmpfile]);
+$request->setOptions(array("cookiestore" => $tmpfile));
server("cookie.inc", function($port) use($request) {
- $request->setOptions(["port" => $port]);
+ $request->setOptions(array("port" => $port));
$client = new http\Client;
echo $client->requeue($request)->send()->getResponse();
echo $client->requeue($request)->send()->getResponse();
});
server("cookie.inc", function($port) use($request) {
- $request->setOptions(["port" => $port]);
+ $request->setOptions(array("port" => $port));
$client = new http\Client;
echo $client->requeue($request)->send()->getResponse();
echo $client->requeue($request)->send()->getResponse();
});
server("cookie.inc", function($port) use($request) {
- $request->setOptions(["port" => $port, "cookiesession" => true]);
+ $request->setOptions(array("port" => $port, "cookiesession" => true));
$client = new http\Client;
echo $client->requeue($request)->send()->getResponse();
echo $client->requeue($request)->send()->getResponse();
});
server("cookie.inc", function($port) use($request) {
- $request->setOptions(["port" => $port, "cookiesession" => false]);
+ $request->setOptions(array("port" => $port, "cookiesession" => false));
$client = new http\Client;
echo $client->requeue($request)->send()->getResponse();
echo $client->requeue($request)->send()->getResponse();
$oo = $opt[$k];
foreach ($v as $kk => $vv) {
if (isset($vv) && $oo[$kk] !== $vv) {
- var_dump([$kk => [$vv, $oo[$kk]]]);
+ var_dump(array($kk => array($vv, $oo[$kk])));
}
}
} else if (isset($v) && $opt[$k] !== $v) {
- var_dump([$k => [$v, $opt[$k]]]);
+ var_dump(array($k => array($v, $opt[$k])));
}
}
var_dump($client === $client->configure($client->getAvailableConfiguration()));
server("proxy.inc", function($port) {
$client = new http\Client;
$request = new http\Client\Request("PUT", "http://localhost:$port");
- $request->setOptions(["resume" => 1, "expect_100_timeout" => 0]);
+ $request->setOptions(array("resume" => 1, "expect_100_timeout" => 0));
$request->getBody()->append("123");
echo $client->enqueue($request)->send()->getResponse();
});
for ($i = 0, $data = str_repeat("a",1024); $i < 128*1024; ++$i) {
$request->getBody()->append($data);
}
- $request->setOptions(["timeout" => 10, "expect_100_timeout" => 0]);
+ $request->setOptions(array("timeout" => 10, "expect_100_timeout" => 0));
$client->enqueue($request);
$client->send();
var_dump($client->getResponse()->getHeaders());
ob_end_flush();
$r->send();
+?>
--EXPECTHEADERS--
Accept-Ranges: bytes
Cache-Control: public,must-revalidate,max-age=0
$req = new http\Env\Request;
$req->setRequestMethod("CONNECT");
-$req->setRequestUrl(["host"=>"www.example.com", "port"=>80]);
+$req->setRequestUrl(array("host"=>"www.example.com", "port"=>80));
echo $req;
<?php
echo "Test\n";
-$headers = [
+$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 = [-1=>"FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE"];
+$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),
<?php
echo "Test\n";
-$headers = [
+$headers = array(
"Na\0me: value",
"Na\nme: value",
"Name:\0value",
"Name:\nvalue",
"Name: val\0ue",
"Name: value\0",
-];
+);
foreach ($headers as $header) {
$parsed = null;
$socket = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
stream_set_blocking($socket[0], 0);
-$headers = [
+$headers = array(
"GET / HTTP/1.1\n",
"Host: localhost","\n",
"Content","-length: 3\n",
"\n",
-];
+);
while ($headers) {
$line = array_shift($headers);
include "server.inc";
function respond($client, $msg) {
- (new http\Env\Response)->setEnvRequest($msg)
+ $r = new http\Env\Response;
+ $r->setEnvRequest($msg)
->setHeader("X-Req", $msg->getRequestUrl())
->send($client);
}
<?php
-function serve(callable $cb) {
+// PHP-5.3
+if (!defined("PHP_BINARY")) {
+ define("PHP_BINARY", PHP_BINDIR.DIRECTORY_SEPARATOR."php");
+}
+
+function serve($cb) {
foreach (range(8000, 9000) as $port) {
if (($server = @stream_socket_server("tcp://localhost:$port"))) {
fprintf(STDERR, "%s\n", $port);
do {
- $R = [$server]; $W = []; $E = [];
+ $R = array($server); $W = array(); $E = array();
$select = stream_select($R, $E, $E, 0, 10000);
if ($select && ($client = stream_socket_accept($server, 1))) {
if (getenv("PHP_HTTP_TEST_SSL")) {
}
}
-function server($handler, callable $cb) {
- proc(PHP_BINARY, [__DIR__."/$handler"], $cb);
+function server($handler, $cb) {
+ proc(PHP_BINARY, array(__DIR__."/$handler"), $cb);
}
-function nghttpd(callable $cb) {
- $spec = [["pipe","r"], ["pipe","w"], ["pipe","w"]];
+function nghttpd($cb) {
+ $spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
foreach (range(8000, 9000) as $port) {
$comm = "exec nghttpd -d html $port http2.key http2.crt";
if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) {
}
-function proc($bin, $args, callable $cb) {
- $spec = [["pipe","r"], ["pipe","w"], ["pipe","w"]];
+function proc($bin, $args, $cb) {
+ $spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
$comm = escapeshellcmd($bin) . " ". implode(" ", array_map("escapeshellarg", $args));
if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) {
$stdin = $pipes[0];
do {
$port = trim(fgets($stderr));
- $R = [$stderr]; $W = []; $E = [];
+ $R = array($stderr); $W = array(); $E = array();
} while (is_numeric($port) && stream_select($R, $W, $E, 0, 10000));
if (is_numeric($port)) {
echo "Test\n";
-function trap(callable $cb) {
+function trap($cb) {
try {
$cb();
} catch (Exception $e) {
}
if (!$string) {
- $s = ["START", "HEADER", "HEADER_DONE", "BODY", "BODY_DUMB", "BODY_LENGTH", "BODY_CHUNK", "BODY_DONE", "UPDATE_CL", "DONE"];
+ $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);
}
}
function skip_http2_test($message = "skip need http2 support (nghttpd in PATH)\n") {
- foreach (explode(":", $_ENV["PATH"]) as $path) {
- if (is_executable($path . "/nghttpd")) {
- return;
+ if (defined("http\\Client\\Curl\\HTTP_VERSION_2_0")) {
+ foreach (explode(":", $_ENV["PATH"]) as $path) {
+ if (is_executable($path . "/nghttpd")) {
+ return;
+ }
}
}
die($message);