Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  Fix Twig deprecation notice
  [DependencyInjection] Fix issue between decorator and service locator index
  do not overwrite the host to request
  • Loading branch information
xabbuh committed Aug 26, 2024
2 parents 5302eae + 4d547e5 commit 4c92046
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CurlHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ public function request(string $method, string $url, array $options = []): Respo
$multi->reset();
}

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

$curlopts[\CURLOPT_RESOLVE] = $resolve;
Expand Down
16 changes: 16 additions & 0 deletions Tests/CurlHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,20 @@ public function testOverridingInternalAttributesUsingCurlOptions()
],
]);
}

public function testKeepAuthorizationHeaderOnRedirectToSameHostWithConfiguredHostToIpAddressMapping()
{
$httpClient = $this->getHttpClient(__FUNCTION__);
$response = $httpClient->request('POST', 'http://127.0.0.1:8057/301', [
'headers' => [
'Authorization' => 'Basic Zm9vOmJhcg==',
],
'resolve' => [
'symfony.com' => '10.10.10.10',
],
]);

$this->assertSame(200, $response->getStatusCode());
$this->assertSame('/302', $response->toArray()['REQUEST_URI'] ?? null);
}
}

0 comments on commit 4c92046

Please sign in to comment.