Skip to content

Commit 82e4790

Browse files
[HttpClient] fix handling of 3xx with no Location header - ignore Content-Length when no body is expected
1 parent 376a4f0 commit 82e4790

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

HttpClient/Test/Fixtures/web/index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
header('Location: ..', true, 302);
8383
break;
8484

85+
case '/304':
86+
header('Content-Length: 10', true, 304);
87+
echo '12345';
88+
return;
89+
8590
case '/307':
8691
header('Location: http://localhost:8057/post', true, 307);
8792
break;

HttpClient/Test/HttpClientTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ public function testBadRequestBody()
260260
$response->getStatusCode();
261261
}
262262

263+
public function test304()
264+
{
265+
$client = $this->getHttpClient(__FUNCTION__);
266+
$response = $client->request('GET', 'http://localhost:8057/304', [
267+
'headers' => ['If-Match' => '"abc"'],
268+
]);
269+
270+
$this->assertSame(304, $response->getStatusCode());
271+
$this->assertSame('', $response->getContent(false));
272+
}
273+
263274
public function testRedirects()
264275
{
265276
$client = $this->getHttpClient(__FUNCTION__);

0 commit comments

Comments
 (0)