Browse Source

Fix response deprecations

Mischa ter Smitten 5 years ago
parent
commit
a9763b9d38

+ 1 - 1
src/Controller/Component/RequestHandlerComponent.php

@@ -287,7 +287,7 @@ class RequestHandlerComponent extends Component
         }
         /** @var \Cake\Controller\Controller $controller */
         $controller = $event->getSubject();
-        $response->body($controller->requestAction($url, [
+        $response->withStringBody($controller->requestAction($url, [
             'return',
             'bare' => false,
             'environment' => [

+ 1 - 1
src/Http/Client/Response.php

@@ -560,7 +560,7 @@ class Response extends Message implements ResponseInterface
      * For example to get the json data as an object:
      *
      * ```
-     * $body = $response->body('json_decode');
+     * $body = $response->getStringBody('json_decode');
      * ```
      *
      * @param callable|null $parser The callback to use to decode

+ 2 - 2
src/Http/Response.php

@@ -510,7 +510,7 @@ class Response implements ResponseInterface
             $this->_file = null;
             $this->_fileRange = [];
         } else {
-            $this->_sendContent($this->body());
+            $this->_sendContent($this->getStringBody());
         }
 
         if (function_exists('fastcgi_finish_request')) {
@@ -624,7 +624,7 @@ class Response implements ResponseInterface
         );
 
         if (in_array($this->_status, [304, 204])) {
-            $this->body('');
+            $this->withStringBody('');
         }
     }
 

+ 1 - 1
src/Http/ResponseTransformer.php

@@ -251,7 +251,7 @@ class ResponseTransformer
     protected static function getStream($response)
     {
         $stream = 'php://memory';
-        $body = $response->body();
+        $body = $response->getStringBody();
         if (is_string($body) && strlen($body)) {
             $stream = new Stream('php://memory', 'wb');
             $stream->write($body);

+ 1 - 1
src/Routing/Dispatcher.php

@@ -65,7 +65,7 @@ class Dispatcher
         $actionDispatcher = new ActionDispatcher(null, $this->getEventManager(), $this->_filters);
         $response = $actionDispatcher->dispatch($request, $response);
         if ($request->getParam('return', null) !== null) {
-            return $response->body();
+            return $response->getStringBody();
         }
 
         return $response->send();

+ 1 - 1
src/Utility/Xml.php

@@ -58,7 +58,7 @@ class Xml
      *
      * $http = new Client();
      * $response = $http->get('http://example.com/example.xml');
-     * $xml = Xml::build($response->body());
+     * $xml = Xml::build($response->getStringBody());
      * ```
      *
      * Building from an array: