@@ -390,10 +390,9 @@ function normalize_nested_file_spec(array $files = []):array{
390
390
* @return \stdClass|array|bool
391
391
*/
392
392
function get_json (ResponseInterface $ response , bool $ assoc = null ){
393
- $ body = $ response ->getBody ();
394
- $ data = \json_decode ($ body ->getContents (), $ assoc );
393
+ $ data = \json_decode ($ response ->getBody ()->__toString (), $ assoc );
395
394
396
- $ body ->rewind ();
395
+ $ response -> getBody () ->rewind ();
397
396
398
397
return $ data ;
399
398
}
@@ -405,10 +404,9 @@ function get_json(ResponseInterface $response, bool $assoc = null){
405
404
* @return \SimpleXMLElement|array|bool
406
405
*/
407
406
function get_xml (ResponseInterface $ response , bool $ assoc = null ){
408
- $ body = $ response ->getBody ();
409
- $ data = \simplexml_load_string ($ body ->getContents ());
407
+ $ data = \simplexml_load_string ($ response ->getBody ()->__toString ());
410
408
411
- $ body ->rewind ();
409
+ $ response -> getBody () ->rewind ();
412
410
413
411
return $ assoc === true
414
412
? \json_decode (\json_encode ($ data ), true ) // cruel
@@ -441,7 +439,10 @@ function message_to_string(MessageInterface $message):string{
441
439
$ msg .= "\r\n" .$ name .': ' .\implode (', ' , $ values );
442
440
}
443
441
444
- return $ msg ."\r\n\r\n" .$ message ->getBody ();
442
+ $ data = $ message ->getBody ()->__toString ();
443
+ $ message ->getBody ()->rewind ();
444
+
445
+ return $ msg ."\r\n\r\n" .$ data ;
445
446
}
446
447
447
448
/**
@@ -452,7 +453,8 @@ function message_to_string(MessageInterface $message):string{
452
453
* @return string
453
454
*/
454
455
function decompress_content (MessageInterface $ message ):string {
455
- $ data = $ message ->getBody ()->getContents ();
456
+ $ data = $ message ->getBody ()->__toString ();
457
+ $ message ->getBody ()->rewind ();
456
458
457
459
switch ($ message ->getHeaderLine ('content-encoding ' )){
458
460
# case 'br' : return \brotli_uncompress($data); // @todo: https://github.com/kjdev/php-ext-brotli
0 commit comments