Skip to content

Commit

Permalink
Fix applying SizeLimitingReadableStream if limit is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed May 9, 2024
1 parent a271b62 commit 04d176c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Interceptor/DecompressResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ private function addAcceptEncodingHeader(Request $request): void
private function decompressResponse(Response $response): Response
{
if (($encoding = $this->determineCompressionEncoding($response))) {
$stream = new DecompressingReadableStream($response->getBody(), $encoding);

$sizeLimit = $response->getRequest()->getBodySizeLimit();
$decompressedBody = new DecompressingReadableStream($response->getBody(), $encoding);
if ($sizeLimit > 0) {
$stream = new SizeLimitingReadableStream($stream, $sizeLimit);
}

$response->setBody(new SizeLimitingReadableStream($decompressedBody, $sizeLimit));
$response->setBody($stream);
$response->removeHeader('content-encoding');
}

Expand Down

0 comments on commit 04d176c

Please sign in to comment.