Merge pull request #19034 from owncloud/http-request-warning

Prevent warning decoding content
This commit is contained in:
Thomas Müller 2015-10-08 21:51:47 +02:00
commit 020bb33150
2 changed files with 24 additions and 1 deletions

View File

@ -410,7 +410,9 @@ class Request implements \ArrayAccess, \Countable, IRequest {
} }
} }
$this->items['parameters'] = array_merge($this->items['parameters'], $params); if (is_array($params)) {
$this->items['parameters'] = array_merge($this->items['parameters'], $params);
}
$this->contentDecoded = true; $this->contentDecoded = true;
} }

View File

@ -202,6 +202,27 @@ class RequestTest extends \Test\TestCase {
$this->assertSame('Joey', $request['nickname']); $this->assertSame('Joey', $request['nickname']);
} }
public function testNotJsonPost() {
global $data;
$data = 'this is not valid json';
$vars = array(
'method' => 'POST',
'server' => array('CONTENT_TYPE' => 'application/json; utf-8')
);
$request = new Request(
$vars,
$this->secureRandom,
$this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
$this->assertEquals('POST', $request->method);
$result = $request->post;
// ensure there's no error attempting to decode the content
}
public function testPatch() { public function testPatch() {
global $data; global $data;
$data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&'); $data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&');