Skip to content

Commit

Permalink
release(1.3.3) - Added is disconnected param logic to streamRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Joosep Jõeleht authored and Joosep Jõeleht committed Jul 6, 2022
1 parent 8e3a9bb commit d7e3742
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
12 changes: 11 additions & 1 deletion src/StreamRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public function __construct($apiBase, $accessToken, $opts = [])
]);
}

/**
* @throws \ErrorException
*/
public function stream(string $method, string $path, ?array $params = [], ?array $headers = [])
{
$params ??= [];
Expand All @@ -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();

Expand All @@ -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);
Expand Down

0 comments on commit d7e3742

Please sign in to comment.