Set up request body caching

pull/151/head
Daniel Stelljes 10 years ago
parent ef76d72b56
commit 703536d2bf

@ -120,6 +120,11 @@ class Request {
*/ */
public $proxy_ip; public $proxy_ip;
/**
* @var mixed Data from the request body
*/
protected static $body;
/** /**
* Constructor. * Constructor.
* *
@ -198,13 +203,18 @@ class Request {
*/ */
public static function getBody() public static function getBody()
{ {
if (!is_null(self::$body)) {
return self::$body;
}
$body = '';
$method = self::getMethod(); $method = self::getMethod();
if ($method == 'POST' || $method == 'PUT') { if ($method == 'POST' || $method == 'PUT') {
return file_get_contents('php://input'); $body = file_get_contents('php://input');
} }
return ''; return self::$body = $body;
} }
/** /**

Loading…
Cancel
Save