Skip to content

Commit d7e3742

Browse files
Joosep JõelehtJoosep Jõeleht
Joosep Jõeleht
authored and
Joosep Jõeleht
committed
release(1.3.3) - Added is disconnected param logic to streamRequest
1 parent 8e3a9bb commit d7e3742

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "",
44
"type": "library",
55
"license": "EUPL-1.1",
6-
"version": "1.3.2",
6+
"version": "1.3.3",
77
"require": {
88
"php": "^7.4|^8.0|^8.1",
99
"ext-curl": "*",

Diff for: src/StreamRequest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function __construct($apiBase, $accessToken, $opts = [])
5454
]);
5555
}
5656

57+
/**
58+
* @throws \ErrorException
59+
*/
5760
public function stream(string $method, string $path, ?array $params = [], ?array $headers = [])
5861
{
5962
$params ??= [];
@@ -66,7 +69,7 @@ public function stream(string $method, string $path, ?array $params = [], ?array
6669
$this->init($min_ob_level);
6770
$this->connect($method, $path, $headers);
6871

69-
$callback = function () use ($method, $path, $headers) {
72+
$callback = function () use ($method, $path, $headers, $params) {
7073
$buffer = '';
7174
$body = self::$_response->getBody();
7275

@@ -76,6 +79,13 @@ public function stream(string $method, string $path, ?array $params = [], ?array
7679
$this->connect($method, $path, $headers);
7780
$buffer = '';
7881
$body = self::$_response->getBody();
82+
83+
}
84+
85+
if (is_callable($params['isDisconnectedCallback'])) {
86+
if (call_user_func($params['isDisconnectedCallback'])) {
87+
break;
88+
}
7989
}
8090

8191
$buffer .= $body->read(1);

0 commit comments

Comments
 (0)