Skip to content

Commit

Permalink
Merge pull request #182 from qMBQx8GH/master
Browse files Browse the repository at this point in the history
fixed progressFunction
  • Loading branch information
isublimity authored Dec 20, 2022
2 parents 3c01fa0 + 19a2b70 commit 740b3a1
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/Transport/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,29 +444,23 @@ public function __findXClickHouseProgress($handle): bool
}

$header = substr($response, 0, $header_size);
if (!$header_size) {
return false;
}

$pos = strrpos($header, 'X-ClickHouse-Summary:');
if (!$pos) {
if (!$header) {
return false;
}

$last = substr($header, $pos);
$data = @json_decode(str_ireplace('X-ClickHouse-Summary:', '', $last), true);
$match = [];
if (preg_match_all('/^X-ClickHouse-(?:Progress|Summary):(.*?)$/im', $header, $match)) {
$data = @json_decode(end($match[1]), true);
if ($data && is_callable($this->xClickHouseProgress)) {

if ($data && is_callable($this->xClickHouseProgress)) {
if (is_array($this->xClickHouseProgress)) {
call_user_func_array($this->xClickHouseProgress, [$data]);
} else {
call_user_func($this->xClickHouseProgress, $data);
}

if (is_array($this->xClickHouseProgress)) {
call_user_func_array($this->xClickHouseProgress, [$data]);
} else {
call_user_func($this->xClickHouseProgress, $data);
}


}

}
return false;
}
Expand Down

0 comments on commit 740b3a1

Please sign in to comment.