diff --git a/Tests/Transport/HeadRequestTest.php b/Tests/Transport/HeadRequestTest.php new file mode 100644 index 00000000..edcaa2a3 --- /dev/null +++ b/Tests/Transport/HeadRequestTest.php @@ -0,0 +1,55 @@ + [$transport, $method]; + } + } + } + + #[DataProvider('transportAndMethodProvider')] + public function testHeadRequestDoesNotWaitForABody(string $transportClass, string $method): void + { + if (!$transportClass::isSupported()) { + $this->markTestSkipped(sprintf('The "%s" adapter is not supported in this environment.', $transportClass)); + } + + if (!\defined('JTEST_HTTP_STUB') && getenv('JTEST_HTTP_STUB') == '') { + $this->markTestSkipped('The Transport test stub has not been configured'); + } + + $stubUrl = \defined('JTEST_HTTP_STUB') ? JTEST_HTTP_STUB : getenv('JTEST_HTTP_STUB'); + $url = substr($stubUrl, 0, strrpos($stubUrl, '/') + 1) . 'content_length.php'; + + $response = (new $transportClass([]))->request($method, new Uri($url), null, [], 5); + + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('100', $response->getHeaderLine('Content-Length')); + $this->assertSame('', (string) $response->getBody()); + } +} diff --git a/Tests/stubs/content_length.php b/Tests/stubs/content_length.php new file mode 100644 index 00000000..dbcf42cd --- /dev/null +++ b/Tests/stubs/content_length.php @@ -0,0 +1,16 @@ +