]> git.mxchange.org Git - friendica.git/commitdiff
Allow a GuzzleResponse body to be queried more than once
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 24 Aug 2021 15:30:11 +0000 (11:30 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 24 Aug 2021 15:30:11 +0000 (11:30 -0400)
- 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

src/Network/GuzzleResponse.php

index b68f2e84359520c4dd253f0623033fba456c518e..3b41f6f6540f18d1838eed48020b6cd12eebafc9 100644 (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();
        }
 }