Skip to content

Commit

Permalink
feat: enable http compression by sending data not with chunked encodi…
Browse files Browse the repository at this point in the history
…ng - if possible
  • Loading branch information
DeepDiver1975 committed May 3, 2023
1 parent f3ae57e commit f704623
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Swoole/SwooleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,15 @@ protected function sendResponseContent(OctaneResponse $octaneResponse, SwooleRes
return;
}

# if the content fits into one chunk -> perform no chunked encoding
if ($length <= $this->chunkSize) {
$swooleResponse->write($content);
} else {
for ($offset = 0; $offset < $length; $offset += $this->chunkSize) {
$swooleResponse->write(substr($content, $offset, $this->chunkSize));
}
$swooleResponse->end($content);

return;
}

for ($offset = 0; $offset < $length; $offset += $this->chunkSize) {
$swooleResponse->write(substr($content, $offset, $this->chunkSize));
}

$swooleResponse->end();
Expand Down

0 comments on commit f704623

Please sign in to comment.