Skip to content

Commit 4c92046

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: Fix Twig deprecation notice [DependencyInjection] Fix issue between decorator and service locator index do not overwrite the host to request
2 parents 5302eae + 4d547e5 commit 4c92046

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

CurlHttpClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ public function request(string $method, string $url, array $options = []): Respo
188188
$multi->reset();
189189
}
190190

191-
foreach ($options['resolve'] as $host => $ip) {
192-
$resolve[] = null === $ip ? "-$host:$port" : "$host:$port:$ip";
193-
$multi->dnsCache->hostnames[$host] = $ip;
194-
$multi->dnsCache->removals["-$host:$port"] = "-$host:$port";
191+
foreach ($options['resolve'] as $resolveHost => $ip) {
192+
$resolve[] = null === $ip ? "-$resolveHost:$port" : "$resolveHost:$port:$ip";
193+
$multi->dnsCache->hostnames[$resolveHost] = $ip;
194+
$multi->dnsCache->removals["-$resolveHost:$port"] = "-$resolveHost:$port";
195195
}
196196

197197
$curlopts[\CURLOPT_RESOLVE] = $resolve;

Tests/CurlHttpClientTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,20 @@ public function testOverridingInternalAttributesUsingCurlOptions()
122122
],
123123
]);
124124
}
125+
126+
public function testKeepAuthorizationHeaderOnRedirectToSameHostWithConfiguredHostToIpAddressMapping()
127+
{
128+
$httpClient = $this->getHttpClient(__FUNCTION__);
129+
$response = $httpClient->request('POST', 'http://127.0.0.1:8057/301', [
130+
'headers' => [
131+
'Authorization' => 'Basic Zm9vOmJhcg==',
132+
],
133+
'resolve' => [
134+
'symfony.com' => '10.10.10.10',
135+
],
136+
]);
137+
138+
$this->assertSame(200, $response->getStatusCode());
139+
$this->assertSame('/302', $response->toArray()['REQUEST_URI'] ?? null);
140+
}
125141
}

0 commit comments

Comments
 (0)