Skip to content

Commit 79a26ca

Browse files
authored
Use (string) $body instead of $body->getContents() for getting contents from StreamInterface. (#2871)
because method `getContents()` only returns the remaining contents in a string.
1 parent b0842dc commit 79a26ca

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Base/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Response implements ResponseInterface
102102

103103
public function __toString()
104104
{
105-
return $this->getBody()->getContents();
105+
return (string) $this->getBody();
106106
}
107107

108108
/**

src/Server/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ protected static function normalizeParsedBody(array $data = [], ?RequestInterfac
480480

481481
try {
482482
$parser = static::getParser();
483-
if ($parser->has($contentType) && $content = $request->getBody()->getContents()) {
483+
if ($parser->has($contentType) && $content = (string) $request->getBody()) {
484484
$data = $parser->parse($content, $contentType);
485485
}
486486
} catch (\InvalidArgumentException $exception) {

0 commit comments

Comments
 (0)