1
0
Fork 0

Allow a GuzzleResponse body to be queried more than once

- Using `StreamInterface->getContents` left the stream index at the end of the stream, which made every subsequent call to `getBody()` return empty string
- Using `StreamInterface->__toString()` magic method correctly seek the stream to the start before reading
This commit is contained in:
Hypolite Petovan 2021-08-24 11:30:11 -04:00
parent e7fdf3c0c3
commit 17944c01ea

View file

@ -147,8 +147,8 @@ class GuzzleResponse extends Response implements IHTTPResult, ResponseInterface
}
/// @todo - fix mismatching use of "getBody()" as string here and parent "getBody()" as streaminterface
public function getBody()
public function getBody(): string
{
return parent::getBody()->getContents();
return (string) parent::getBody();
}
}