From 4f223ba11dbd3679ed4de7b13d0dad66dfc92dab Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Sat, 13 Jan 2018 18:08:07 +0700 Subject: [PATCH] Fixed PSR request parsing, broken after recent changes --- src/Server/Helper.php | 6 ------ tests/Server/RequestParsingTest.php | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Server/Helper.php b/src/Server/Helper.php index 8bc8588..1957fec 100644 --- a/src/Server/Helper.php +++ b/src/Server/Helper.php @@ -499,12 +499,6 @@ class Helper Utils::printSafeJson($bodyParams) ); } - - if (empty($bodyParams)) { - throw new InvariantViolation( - "PSR-7 request is expected to provide parsed body for \"application/json\" requests but got empty array" - ); - } } else { $bodyParams = $request->getParsedBody(); diff --git a/tests/Server/RequestParsingTest.php b/tests/Server/RequestParsingTest.php index be49492..49f32fb 100644 --- a/tests/Server/RequestParsingTest.php +++ b/tests/Server/RequestParsingTest.php @@ -177,12 +177,12 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase public function testFailsParsingNonPreParsedPsrRequest() { try { - $this->parsePsrRequest('application/json', json_encode([])); + $this->parsePsrRequest('application/json', json_encode(null)); $this->fail('Expected exception not thrown'); } catch (InvariantViolation $e) { // Expecting parsing exception to be thrown somewhere else: $this->assertEquals( - 'PSR-7 request is expected to provide parsed body for "application/json" requests but got empty array', + 'PSR-7 request is expected to provide parsed body for "application/json" requests but got null', $e->getMessage() ); }