Skip to content

Commit

Permalink
Ppsl: Input_Instance lazy reading for php://input (fuel#2125)
Browse files Browse the repository at this point in the history
We should use on demand lazy reading for php://input, otherwise in nested Requests with php 5.6+ we have redundant re-reading it, and have unnecessary memory consumption and potentially DDoS, depending on the settings of frontend server, typically nginx (client_max_body_size).
  • Loading branch information
Illirgway authored and WanWizard committed Sep 20, 2019
1 parent 007c25a commit 9d6f4e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions classes/input/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public function __construct(Request $new = null, Input_Instance $input = null)
// store the associated request
$this->request = $new;

// get php raw input
$this->raw_input = file_get_contents('php://input');

// was an input instance passed?
if ($input)
{
Expand Down Expand Up @@ -328,6 +325,12 @@ public function method($default = 'GET')
*/
public function raw()
{
if ($this->raw_input === null)
{
// get php raw input
$this->raw_input = file_get_contents('php://input');
}

return $this->raw_input;
}

Expand Down

0 comments on commit 9d6f4e6

Please sign in to comment.