summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-10-03 03:56:37 +0200
committerThomas Tanghus <thomas@tanghus.net>2013-10-03 03:56:37 +0200
commitaedc427ffd73f9ab249f1722c197205bc366ed8d (patch)
tree9d9e26d969ea3566f1b75fe605b7f6745115b4e4 /lib
parent8a018d7a59047ef45bfa71b4f07db11a504085b8 (diff)
downloadnextcloud-server-aedc427ffd73f9ab249f1722c197205bc366ed8d.tar.gz
nextcloud-server-aedc427ffd73f9ab249f1722c197205bc366ed8d.zip
Fix fix of POST :P
Diffstat (limited to 'lib')
-rw-r--r--lib/private/appframework/http/request.php21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index b45ac2f0097..f152956c8cf 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -31,6 +31,7 @@ use OCP\IRequest;
class Request implements \ArrayAccess, \Countable, IRequest {
+ protected $inputStream;
protected $content;
protected $items = array();
protected $allowedKeys = array(
@@ -66,12 +67,19 @@ class Request implements \ArrayAccess, \Countable, IRequest {
: array();
}
+ if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
+ && in_array('fakeinput', stream_get_wrappers())) {
+ $this->inputStream = 'fakeinput://data';
+ } else {
+ $this->inputStream = 'php://input';
+ }
+
// Only 'application/x-www-form-urlencoded' requests are automatically
// transformed by PHP, 'application/json' must be decoded manually.
if ($this->method === 'POST'
&& strpos($this->getHeader('Content-Type'), 'application/json') !== false
) {
- $this->items['params'] = $this->items['post'] = json_decode(file_get_contents('php://input'), true);
+ $this->items['params'] = $this->items['post'] = json_decode(file_get_contents($this->inputStream), true);
}
$this->items['parameters'] = array_merge(
@@ -311,24 +319,17 @@ class Request implements \ArrayAccess, \Countable, IRequest {
);
}
- if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
- && in_array('fakeinput', stream_get_wrappers())) {
- $stream = 'fakeinput://data';
- } else {
- $stream = 'php://input';
- }
-
// If the content can't be parsed into an array then return a stream resource.
if ($this->method === 'PUT'
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
) {
$this->content = false;
- return fopen($stream, 'rb');
+ return fopen($this->inputStream, 'rb');
}
if (is_null($this->content)) {
- $this->content = file_get_contents($stream);
+ $this->content = file_get_contents($this->inputStream);
/*
* Normal jquery ajax requests are sent as application/x-www-form-urlencoded