Skip to content

Commit 7972a40

Browse files
Merge branch '4.3' into 4.4
* 4.3: [OptionsResolve] Revert change in tests for a not-merged change in code [HttpClient] fix handling of 3xx with no Location header - ignore Content-Length when no body is expected [Workflow] Made the configuration more robust for the 'property' key [Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible #30432 fix an error message fix paths to detect code owners [HttpClient] ignore the body of responses to HEAD requests [Validator] Ensure numeric subpaths do not cause errors on PHP 7.4 [SecurityBundle] Fix wrong assertion Remove unused local variables in tests [Yaml][Parser] Remove the getLastLineNumberBeforeDeprecation() internal unused method Make sure to collect child forms created on *_SET_DATA events [WebProfilerBundle] Improve display in Email panel for dark theme do not render errors for checkboxes twice
2 parents ec07bab + 82e4790 commit 7972a40

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ public function testGetRequest()
7272
$response->getContent();
7373
}
7474

75+
public function testHeadRequest()
76+
{
77+
$client = $this->getHttpClient(__FUNCTION__);
78+
$response = $client->request('HEAD', 'http://localhost:8057', [
79+
'headers' => ['Foo' => 'baR'],
80+
'user_data' => $data = new \stdClass(),
81+
]);
82+
83+
$this->assertSame([], $response->getInfo('response_headers'));
84+
$this->assertSame($data, $response->getInfo()['user_data']);
85+
$this->assertSame(200, $response->getStatusCode());
86+
87+
$info = $response->getInfo();
88+
$this->assertNull($info['error']);
89+
$this->assertSame(0, $info['redirect_count']);
90+
$this->assertSame('HTTP/1.1 200 OK', $info['response_headers'][0]);
91+
$this->assertSame('Host: localhost:8057', $info['response_headers'][1]);
92+
$this->assertSame('http://localhost:8057/', $info['url']);
93+
94+
$headers = $response->getHeaders();
95+
96+
$this->assertSame('localhost:8057', $headers['host'][0]);
97+
$this->assertSame(['application/json'], $headers['content-type']);
98+
99+
$this->assertSame('', $response->getContent());
100+
}
101+
75102
public function testNonBufferedGetRequest()
76103
{
77104
$client = $this->getHttpClient(__FUNCTION__);
@@ -297,6 +324,17 @@ public function testBadRequestBody()
297324
$response->getStatusCode();
298325
}
299326

327+
public function test304()
328+
{
329+
$client = $this->getHttpClient(__FUNCTION__);
330+
$response = $client->request('GET', 'http://localhost:8057/304', [
331+
'headers' => ['If-Match' => '"abc"'],
332+
]);
333+
334+
$this->assertSame(304, $response->getStatusCode());
335+
$this->assertSame('', $response->getContent(false));
336+
}
337+
300338
public function testRedirects()
301339
{
302340
$client = $this->getHttpClient(__FUNCTION__);

0 commit comments

Comments
 (0)