Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
git config --global core.eol lf

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v5

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -50,7 +50,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-dir)"

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/PsrMessageStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class PsrMessageStream implements StreamInterface

private int $position = 0;

public function __construct(private readonly ReadableStream $source)
public function __construct(private readonly ReadableStream $source, private readonly ?int $size = null)
{
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public function getMetadata(?string $key = null): ?array

public function getSize(): ?int
{
return null;
return $this->size;
}

public function isReadable(): bool
Expand Down
5 changes: 4 additions & 1 deletion src/PsrAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public function toPsrResponse(Response $response): PsrResponse
$psrResponse = $psrResponse->withAddedHeader($headerName, $headerValue);
}

return $psrResponse->withBody(new PsrMessageStream($response->getBody()));
$contentLength = $response->getHeader('Content-Length');
$size = $contentLength === null ? null : \max(0, (int) $contentLength);

return $psrResponse->withBody(new PsrMessageStream($response->getBody(), $size));
}

/**
Expand Down
Loading