class Observer implements SplObserver
{
#[ReturnTypeWillChange]
- function update(SplSubject $client, http\Client\Request $request = null, StdClass $progress = null) {
+ 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);
--TEST--
client curl user handler
--SKIPIF--
-<?php
+<?php
include "skipif.inc";
skip_client_test();
-?>
+?>
--FILE--
-<?php
+<?php
echo "Test\n";
class UserHandler implements http\Client\Curl\User
private $R = array();
private $W = array();
private $timeout = 1000;
-
+
function __construct(http\Client $client) {
$this->client = $client;
}
-
+
function init($run) {
$this->run = $run;
}
-
+
function timer(int $timeout_ms) {
echo "T";
$this->timeout = $timeout_ms;
}
-
+
function socket($socket, int $action) {
echo "S";
-
+
switch ($action) {
case self::POLL_NONE:
break;
echo "U";
unset($this->fds["R"][$r]);
}
-
+
if (false !== ($w = array_search($socket, $this->fds["W"], true))) {
echo "U";
unset($this->fds["W"][$w]);
}
-
+
break;
-
+
default:
if ($action & self::POLL_IN) {
if (!in_array($socket, $this->fds["R"], true)) {
break;
}
}
-
+
function once() {
echo "O";
-
+
foreach ($this->W as $w) {
call_user_func($this->run, $this->client, $w, self::POLL_OUT);
}
}
return count($this->client);
}
-
- function wait(int $timeout_ms = null) {
+
+ function wait(?int $timeout_ms = null) {
echo "W";
-
+
if ($timeout_ms === null) {
$timeout_ms = $this->timeout;
}
$ts = floor($timeout_ms / 1000);
$tu = ($timeout_ms % 1000) * 1000;
-
+
extract($this->fds);
-
+
if (($wfds = count($R) + count($W))) {
$nfds = stream_select($R, $W, $E, $ts, $tu);
} else {
}
$this->R = (array) $R;
$this->W = (array) $W;
-
+
if ($nfds === false) {
return false;
}
}
call_user_func($this->run, $this->client);
}
-
+
return true;
}
-
+
function send() {
$this->wait();
$this->once();
--TEST--
invalid HTTP info
--SKIPIF--
-<?php
+<?php
include "skipif.inc";
?>
--INI--
zend.exception_ignore_args=off
--FILE--
-<?php
+<?php
echo "Test\n";
function trap($cb) {
try {
$cb();
- } catch (Exception $e) {
- echo $e,"\n";
+ } catch (Exception $e) {
+ echo $e,"\n";
}
}
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): {closure}()
+#1 %sinfo002.php(%d): {closure%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): {closure}()
+#1 %sinfo002.php(%d): {closure%s}()
#2 %sinfo002.php(%d): trap(Object(Closure))
#3 {main}
HTTP/1.1 200