Skip to content

Commit

Permalink
Merge pull request #53 from utopia-php/fix-curl-error
Browse files Browse the repository at this point in the history
Fix: CURL Chunk processing
  • Loading branch information
christyjacob4 authored Aug 13, 2024
2 parents 0d7e722 + 00e7805 commit 9d2ff89
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Orchestration/Adapter/DockerAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ protected function streamCall(string $url, int $timeout = -1): array
return 0;
}

$originalSize = \mb_strlen($str);
$originalSize = \strlen($str);

while (! empty($str)) {
while (\strlen($str) > 0) {
if ($isHeader) {
$header = \unpack('Ctype/Cfill1/Cfill2/Cfill3/Nsize', $str);
$str = \mb_strcut($str, 8, null);
$str = \substr($str, 8, null);
$isHeader = false;
$currentHeader = $header;
} else {
$size = $currentHeader['size'];
$type = $currentHeader['type'];

if (\strlen($str) >= $size) {
$currentData .= \mb_substr($str, 0, $size);
$str = \mb_strcut($str, $size, null);
$currentData .= \substr($str, 0, $size);
$str = \substr($str, $size, null);
$isHeader = true;
$currentHeader = null;

Expand All @@ -164,7 +164,7 @@ protected function streamCall(string $url, int $timeout = -1): array
}
$currentData = '';
} else {
$currentHeader['size'] -= \mb_strlen($str);
$currentHeader['size'] -= \strlen($str);
$currentData .= $str;
$str = '';
}
Expand Down

0 comments on commit 9d2ff89

Please sign in to comment.