From 703536d2bf31e7eda6d3c16a5f5a5d0198a6d68c Mon Sep 17 00:00:00 2001 From: Daniel Stelljes Date: Mon, 29 Sep 2014 21:55:40 -0500 Subject: [PATCH] Set up request body caching --- flight/net/Request.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/flight/net/Request.php b/flight/net/Request.php index 628c4f3..c2142e1 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -120,6 +120,11 @@ class Request { */ public $proxy_ip; + /** + * @var mixed Data from the request body + */ + protected static $body; + /** * Constructor. * @@ -198,13 +203,18 @@ class Request { */ public static function getBody() { + if (!is_null(self::$body)) { + return self::$body; + } + + $body = ''; $method = self::getMethod(); if ($method == 'POST' || $method == 'PUT') { - return file_get_contents('php://input'); + $body = file_get_contents('php://input'); } - return ''; + return self::$body = $body; } /**