From b0be2c79dce5b1b7da43cc33462c4fe2a981e932 Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Mon, 30 Sep 2013 16:24:47 +0200
Subject: [PATCH] Remove JSON request parsing from Server

---
 lib/appframework/http/request.php | 5 +----
 lib/server.php                    | 9 ---------
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/lib/appframework/http/request.php b/lib/appframework/http/request.php
index 3426f0bf75..8c1c2f8ec8 100644
--- a/lib/appframework/http/request.php
+++ b/lib/appframework/http/request.php
@@ -42,14 +42,12 @@ class Request implements \ArrayAccess, \Countable, IRequest {
 		'env',
 		'cookies',
 		'urlParams',
-		'params',
 		'parameters',
 		'method'
 	);
 
 	/**
 	 * @param array $vars An associative array with the following optional values:
-	 * @param array 'params' the parsed json array
 	 * @param array 'urlParams' the parameters which were matched from the URL
 	 * @param array 'get' the $_GET array
 	 * @param array|string 'post' the $_POST array or JSON string
@@ -74,11 +72,10 @@ class Request implements \ArrayAccess, \Countable, IRequest {
 		if (isset($this->items['post'])
 			&& strpos($this->getHeader('Content-Type'), 'application/json') !== false
 			&& is_string($this->items['post'])) {
-			$this->items['post'] = json_decode($this->items['post'], true);
+			$this->items['params'] = $this->items['post'] = json_decode($this->items['post'], true);
 		}
 
 		$this->items['parameters'] = array_merge(
-			$this->items['params'],
 			$this->items['get'],
 			$this->items['post'],
 			$this->items['urlParams']
diff --git a/lib/server.php b/lib/server.php
index cabb15324e..ef2007663c 100644
--- a/lib/server.php
+++ b/lib/server.php
@@ -22,14 +22,6 @@ class Server extends SimpleContainer implements IServerContainer {
 			return new ContactsManager();
 		});
 		$this->registerService('Request', function($c) {
-			$params = array();
-
-			// we json decode the body only in case of content type json
-			if (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'],'json') !== false ) {
-				$params = json_decode(file_get_contents('php://input'), true);
-				$params = is_array($params) ? $params: array();
-			}
-
 			return new Request(
 				array(
 					'get' => $_GET,
@@ -41,7 +33,6 @@ class Server extends SimpleContainer implements IServerContainer {
 					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
 						? $_SERVER['REQUEST_METHOD']
 						: null,
-					'params' => $params,
 					'urlParams' => $c['urlParams']
 				)
 			);
-- 
GitLab