diff --git a/VERSION b/VERSION index f6f3dc1..03412e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2503.150240 +0.2503.150248 diff --git a/tests/HttpFormContentTest.php b/tests/HttpFormContentTest.php index 48dda4e..4ce1af0 100644 --- a/tests/HttpFormContentTest.php +++ b/tests/HttpFormContentTest.php @@ -80,6 +80,14 @@ final class HttpFormContentTest extends TestCase { $this->assertEquals($expected, $extracted); } + public function testMultipartFormEmpty(): void { + $form = MultipartFormContent::parseStream( + Stream::createStream("------geckoformboundaryf31072d915603e48fe9e0e5393a89f20--\r\n"), + '----geckoformboundaryf31072d915603e48fe9e0e5393a89f20' + ); + $this->assertEquals(0, count($form->params)); + } + public function testMultipartForm(): void { $form = MultipartFormContent::parseStream( Stream::createStreamFromFile(__DIR__ . '/HttpFormContentTest-multipart.bin', 'rb'), diff --git a/tests/RouterTest.php b/tests/RouterTest.php index e497a46..63a139b 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -297,6 +297,11 @@ final class RouterTest extends TestCase { $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('urlencoded:mewow', (string)$response->getBody()); + // an empty string is valid too + $response = $router->handle(HttpRequest::createRequestWithBody('POST', '/optional-form', ['Content-Type' => ['application/x-www-form-urlencoded']], Stream::createStream(''))); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('urlencoded:', (string)$response->getBody()); + $response = $router->handle(HttpRequest::createRequestWithBody('POST', '/optional-form', ['Content-Type' => ['multipart/form-data; boundary="--soap12345"']], Stream::createStream(implode("\r\n", [ '----soap12345', 'Content-Disposition: form-data; name="test"', @@ -308,6 +313,13 @@ final class RouterTest extends TestCase { $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('multipart:wowof', (string)$response->getBody()); + $response = $router->handle(HttpRequest::createRequestWithBody('POST', '/optional-form', ['Content-Type' => ['multipart/form-data; boundary="--soap12345"']], Stream::createStream(implode("\r\n", [ + '----soap12345--', + '', + ])))); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('multipart:', (string)$response->getBody()); + $response = $router->handle(HttpRequest::createRequestWithoutBody('POST', '/required-urlencoded')); $this->assertEquals(400, $response->getStatusCode());