]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove JSON request parsing from Server
authorThomas Tanghus <thomas@tanghus.net>
Mon, 30 Sep 2013 14:24:47 +0000 (16:24 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Tue, 1 Oct 2013 18:15:04 +0000 (20:15 +0200)
lib/private/appframework/http/request.php
lib/private/server.php

index 3426f0bf7526634b1403cf7b85322fa8da91286e..8c1c2f8ec8ccdf672fa8edf4b707e137b67333e6 100644 (file)
@@ -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']
index cabb15324ec36169ff0d950211bf95af008ae3a4..ef2007663c691e48859b2659b3cf453ea229a285 100644 (file)
@@ -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']
                                )
                        );