diff --git a/composer.json b/composer.json index 6a4eaa1..4095d61 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "", "type": "library", "license": "EUPL-1.1", - "version": "1.3.2", + "version": "1.3.3", "require": { "php": "^7.4|^8.0|^8.1", "ext-curl": "*", diff --git a/src/StreamRequest.php b/src/StreamRequest.php index 5917bad..dfb60fb 100644 --- a/src/StreamRequest.php +++ b/src/StreamRequest.php @@ -54,6 +54,9 @@ public function __construct($apiBase, $accessToken, $opts = []) ]); } + /** + * @throws \ErrorException + */ public function stream(string $method, string $path, ?array $params = [], ?array $headers = []) { $params ??= []; @@ -66,7 +69,7 @@ public function stream(string $method, string $path, ?array $params = [], ?array $this->init($min_ob_level); $this->connect($method, $path, $headers); - $callback = function () use ($method, $path, $headers) { + $callback = function () use ($method, $path, $headers, $params) { $buffer = ''; $body = self::$_response->getBody(); @@ -76,6 +79,13 @@ public function stream(string $method, string $path, ?array $params = [], ?array $this->connect($method, $path, $headers); $buffer = ''; $body = self::$_response->getBody(); + + } + + if (is_callable($params['isDisconnectedCallback'])) { + if (call_user_func($params['isDisconnectedCallback'])) { + break; + } } $buffer .= $body->read(1);