From 745aefc46f428af20449a56160e7559a7ab4c210 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 18 Jun 2016 22:27:55 -0400 Subject: [PATCH] Don't call getSize() getSize() can be expensive, instead read the stream and conditionally assign the input with the stream contents. --- src/Http/RequestTransformer.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Http/RequestTransformer.php b/src/Http/RequestTransformer.php index ee36dbf40c7..d2b50a75806 100644 --- a/src/Http/RequestTransformer.php +++ b/src/Http/RequestTransformer.php @@ -48,11 +48,8 @@ public static function toCake(PsrRequest $request) $post = Hash::merge($post, $files); } - $input = null; - $stream = $request->getBody(); - if ($stream->getSize()) { - $input = $stream->getContents(); - } + $input = $request->getBody()->getContents(); + $input = $input === '' ? null : $input; return new CakeRequest([ 'query' => $request->getQueryParams(),