File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ final class PsrMessageStream implements StreamInterface
1818
1919 private int $ position = 0 ;
2020
21- public function __construct (private readonly ReadableStream $ source )
21+ public function __construct (private readonly ReadableStream $ source, private readonly ? int $ size = null )
2222 {
2323 }
2424
@@ -64,7 +64,7 @@ public function getMetadata(?string $key = null): ?array
6464
6565 public function getSize (): ?int
6666 {
67- return null ;
67+ return $ this -> size ;
6868 }
6969
7070 public function isReadable (): bool
Original file line number Diff line number Diff line change @@ -74,7 +74,13 @@ public function toPsrResponse(Response $response): PsrResponse
7474 $ psrResponse = $ psrResponse ->withAddedHeader ($ headerName , $ headerValue );
7575 }
7676
77- return $ psrResponse ->withBody (new PsrMessageStream ($ response ->getBody ()));
77+ $ size = (int ) $ response ->getHeader ('Content-Length ' );
78+
79+ if ($ size <= 0 ) {
80+ $ size = null ;
81+ }
82+
83+ return $ psrResponse ->withBody (new PsrMessageStream ($ response ->getBody (), $ size ));
7884 }
7985
8086 /**
You can’t perform that action at this time.
0 commit comments