Browse Source

Don't call getSize()

getSize() can be expensive, instead read the stream and conditionally
assign the input with the stream contents.
Mark Story 9 years ago
parent
commit
745aefc46f
1 changed files with 2 additions and 5 deletions
  1. 2 5
      src/Http/RequestTransformer.php

+ 2 - 5
src/Http/RequestTransformer.php

@@ -48,11 +48,8 @@ class RequestTransformer
             $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(),