Skip to content

Commit b35a27a

Browse files
committed
:octocat: rewind!
1 parent 3cc6534 commit b35a27a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Psr7/message_helpers.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,12 @@ function normalize_nested_file_spec(array $files = []):array{
390390
* @return \stdClass|array|bool
391391
*/
392392
function get_json(ResponseInterface $response, bool $assoc = null){
393-
return \json_decode($response->getBody()->getContents(), $assoc);
393+
$body = $response->getBody();
394+
$data = \json_decode($body->getContents(), $assoc);
395+
396+
$body->rewind();
397+
398+
return $data;
394399
}
395400

396401
/**
@@ -400,7 +405,10 @@ function get_json(ResponseInterface $response, bool $assoc = null){
400405
* @return \SimpleXMLElement|array|bool
401406
*/
402407
function get_xml(ResponseInterface $response, bool $assoc = null){
403-
$data = \simplexml_load_string($response->getBody()->getContents());
408+
$body = $response->getBody();
409+
$data = \simplexml_load_string($body->getContents());
410+
411+
$body->rewind();
404412

405413
return $assoc === true
406414
? \json_decode(\json_encode($data), true) // cruel

0 commit comments

Comments
 (0)