summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-04-04 10:25:13 +0200
committerGitHub <noreply@github.com>2017-04-04 10:25:13 +0200
commit0d69b52fde739776242fdc0780c0e90d7faefa23 (patch)
tree6310af437a3ebced54a9cbb79369d9bc6a7428b9
parentc0972a26ed6737bcc9d0288f51c0371b98c81a61 (diff)
parent2a9192334eb6de56b55d5d9c1faab51ca2de2f9e (diff)
downloadnextcloud-server-0d69b52fde739776242fdc0780c0e90d7faefa23.tar.gz
nextcloud-server-0d69b52fde739776242fdc0780c0e90d7faefa23.zip
Merge pull request #4147 from nextcloud/fix_3890
Don't try to parse empty body if there is no body
-rw-r--r--lib/private/AppFramework/Http/Request.php2
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php
index fd43d468568..3f1e6fd951a 100644
--- a/lib/private/AppFramework/Http/Request.php
+++ b/lib/private/AppFramework/Http/Request.php
@@ -401,6 +401,8 @@ class Request implements \ArrayAccess, \Countable, IRequest {
protected function getContent() {
// If the content can't be parsed into an array then return a stream resource.
if ($this->method === 'PUT'
+ && $this->getHeader('Content-Length') !== 0
+ && $this->getHeader('Content-Length') !== null
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
) {
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index cc4bbee2d8d..f80bffcb480 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -305,7 +305,10 @@ class RequestTest extends \Test\TestCase {
$vars = array(
'put' => $data,
'method' => 'PUT',
- 'server' => array('CONTENT_TYPE' => 'image/png'),
+ 'server' => [
+ 'CONTENT_TYPE' => 'image/png',
+ 'CONTENT_LENGTH' => strlen($data)
+ ],
);
$request = new Request(