Skip to content

Commit

Permalink
Don't call getSize()
Browse files Browse the repository at this point in the history
getSize() can be expensive, instead read the stream and conditionally
assign the input with the stream contents.
  • Loading branch information
markstory committed Jun 19, 2016
1 parent a8567c5 commit 745aefc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Http/RequestTransformer.php
Expand Up @@ -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(),
Expand Down

0 comments on commit 745aefc

Please sign in to comment.