Add HTTP finishes with no content-length test for
@@ -78,4 +78,30 @@ final class ClientTest extends TestCase
$wr::wait($wr);
}
+
+ public function testFinishWithNoContentLength(): void
+ {
+ $server = new Socket(Socket::TYPE_TCP);
+ $server->bind('127.0.0.1')->listen();
+
+ $wr = new WaitReference();
+ Coroutine::run(static function () use ($server, $wr): void {
+ $connection = $server->accept();
+ $connection->send(
+ "HTTP/1.1 200 OK\r\n" .
+ "Host: {$server->getSockAddress()}:{$server->getSockPort()}\r\n" .
+ "Connection: close\r\n" .
+ "Content-type: text/html; charset=UTF-8\r\n" .
+ "\r\n"
+ );
+ $connection->close();
+ });
+
+ $client = new Client();
+ $client->connect($server->getSockAddress(), $server->getSockPort());
+ $response = $client->sendRequest(new HttpRequest());
+ $this->assertSame(Status::OK, $response->getStatusCode());
+
+ $wr::wait($wr);
+ }
}
