Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xabbuh committed Sep 17, 2024
2 parents 2898645 + 0dc153b commit 2af7c5a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Internal/CurlClientState.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function __construct(int $maxHostConnections, int $maxPendingPushes)
if (\defined('CURLPIPE_MULTIPLEX')) {
curl_multi_setopt($this->handle, \CURLMOPT_PIPELINING, \CURLPIPE_MULTIPLEX);
}
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX) ? 0 : $maxHostConnections;
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS') && 0 < $maxHostConnections) {
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, $maxHostConnections) ? 4294967295 : $maxHostConnections;
}
if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) {
curl_multi_setopt($this->handle, \CURLMOPT_MAXCONNECTS, $maxHostConnections);
Expand Down
30 changes: 30 additions & 0 deletions Tests/CurlHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,34 @@ public function testKeepAuthorizationHeaderOnRedirectToSameHostWithConfiguredHos
$this->assertSame(200, $response->getStatusCode());
$this->assertSame('/302', $response->toArray()['REQUEST_URI'] ?? null);
}

/**
* @group integration
*/
public function testMaxConnections()
{
foreach ($ports = [80, 8681, 8682, 8683, 8684] as $port) {
if (!($fp = @fsockopen('localhost', $port, $errorCode, $errorMessage, 2))) {
self::markTestSkipped('FrankenPHP is not running');
}
fclose($fp);
}

$httpClient = $this->getHttpClient(__FUNCTION__);

$expectedResults = [
[false, false, false, false, false],
[true, true, true, true, true],
[true, true, true, true, true],
];

foreach ($expectedResults as $expectedResult) {
foreach ($ports as $i => $port) {
$response = $httpClient->request('GET', \sprintf('http://localhost:%s/http-client', $port));
$response->getContent();

self::assertSame($expectedResult[$i], str_contains($response->getInfo('debug'), 'Re-using existing connection'));
}
}
}
}
12 changes: 12 additions & 0 deletions Tests/Fixtures/response-functional/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

echo 'Success';

0 comments on commit 2af7c5a

Please sign in to comment.