Skip to content

Commit 2af7c5a

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: [Serializer] Fix for method named `get()` [Notifier][TurboSMS] Process partial accepted response from transport [HttpClient] Fix setting CURLMOPT_MAXCONNECTS throw a meaningful exception when parsing dotenv files with BOM [FrameworkBundle] Fix schema & finish incomplete tests for lock & semaphore config [Cache] Fix RedisSentinel params types [FrameworkBundle] Fix service reset between tests [Uid][Serializer][Validator] Mention RFC 9562 make sure temp files can be cleaned up on Windows
2 parents 2898645 + 0dc153b commit 2af7c5a

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

Internal/CurlClientState.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function __construct(int $maxHostConnections, int $maxPendingPushes)
4949
if (\defined('CURLPIPE_MULTIPLEX')) {
5050
curl_multi_setopt($this->handle, \CURLMOPT_PIPELINING, \CURLPIPE_MULTIPLEX);
5151
}
52-
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
53-
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX) ? 0 : $maxHostConnections;
52+
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS') && 0 < $maxHostConnections) {
53+
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, $maxHostConnections) ? 4294967295 : $maxHostConnections;
5454
}
5555
if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) {
5656
curl_multi_setopt($this->handle, \CURLMOPT_MAXCONNECTS, $maxHostConnections);

Tests/CurlHttpClientTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,34 @@ public function testKeepAuthorizationHeaderOnRedirectToSameHostWithConfiguredHos
138138
$this->assertSame(200, $response->getStatusCode());
139139
$this->assertSame('/302', $response->toArray()['REQUEST_URI'] ?? null);
140140
}
141+
142+
/**
143+
* @group integration
144+
*/
145+
public function testMaxConnections()
146+
{
147+
foreach ($ports = [80, 8681, 8682, 8683, 8684] as $port) {
148+
if (!($fp = @fsockopen('localhost', $port, $errorCode, $errorMessage, 2))) {
149+
self::markTestSkipped('FrankenPHP is not running');
150+
}
151+
fclose($fp);
152+
}
153+
154+
$httpClient = $this->getHttpClient(__FUNCTION__);
155+
156+
$expectedResults = [
157+
[false, false, false, false, false],
158+
[true, true, true, true, true],
159+
[true, true, true, true, true],
160+
];
161+
162+
foreach ($expectedResults as $expectedResult) {
163+
foreach ($ports as $i => $port) {
164+
$response = $httpClient->request('GET', \sprintf('http://localhost:%s/http-client', $port));
165+
$response->getContent();
166+
167+
self::assertSame($expectedResult[$i], str_contains($response->getInfo('debug'), 'Re-using existing connection'));
168+
}
169+
}
170+
}
141171
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
echo 'Success';

0 commit comments

Comments
 (0)