Skip to content

[HttpClient] Remove support for amphp/http-client < 5 #60712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
442970b
[JsonPath] Always use brackets notation with `JsonPath::key()`
alexandre-daubois Jun 3, 2025
e9eb3e7
bug #60668 [JsonPath] Always use brackets notation with `JsonPath::ke…
nicolas-grekas Jun 4, 2025
8092ffd
[Security] Keep roles when serializing tokens
nicolas-grekas Jun 4, 2025
42e5ad5
bug #60688 [Security] Keep roles when serializing tokens (nicolas-gre…
nicolas-grekas Jun 4, 2025
0291ea1
Revert "bug #60564 [FrameworkBundle] ensureKernelShutdown in tearDown…
nicolas-grekas Jun 4, 2025
c193b98
[FrameworkBundle] ensureKernelShutdown in tearDownAfterClass
cquintana92 May 27, 2025
de57965
bug #60693 [FrameworkBundle] ensureKernelShutdown in tearDownAfterCla…
nicolas-grekas Jun 4, 2025
6156095
cs tweak
nicolas-grekas Jun 5, 2025
2547946
[WebProfilerBundle] Fix typos in routing config deprecation messages
dheineman Jun 5, 2025
a784ff8
minor #60703 [WebProfilerBundle] Fix typos in routing config deprecat…
OskarStark Jun 5, 2025
dc09be9
Fix leftover
nicolas-grekas Jun 5, 2025
542cc71
[Security] conflict with event-subscriber v8
nicolas-grekas Jun 5, 2025
851c22c
[HttpClient] Suggest amphp/http-client v5 by default
nicolas-grekas Jun 5, 2025
959b0ff
Merge branch '6.4' into 7.2
nicolas-grekas Jun 5, 2025
02d4200
Merge branch '7.2' into 7.3
nicolas-grekas Jun 5, 2025
9ec87bf
minor #60713 [HttpClient] Suggest amphp/http-client v5 by default (ni…
nicolas-grekas Jun 5, 2025
3733986
Merge branch '7.3' into 7.4
nicolas-grekas Jun 5, 2025
c35e218
minor #60714 [Security] conflict with event-subscriber v8 (nicolas-gr…
nicolas-grekas Jun 5, 2025
3783b01
Merge branch '7.4' into 8.0
nicolas-grekas Jun 5, 2025
2cc9de0
[HttpClient] Remove support for amphp/http-client < 5
nicolas-grekas Jun 5, 2025
3a90806
[HttpClient] Rename amphp "V5" classes
nicolas-grekas Jun 5, 2025
685f224
[HttpClient] Remove setLogger() methods on decorators
nicolas-grekas Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[HttpClient] Remove support for amphp/http-client < 5
  • Loading branch information
nicolas-grekas committed Jun 5, 2025
commit 2cc9de0f30ba2d55b8db828d8f5ced287ad0b846
1 change: 0 additions & 1 deletion .github/patch-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
case false !== strpos($file, '/src/Symfony/Component/HttpClient/Internal/') && str_contains($file, 'V4'):
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
case false !== strpos($file, '/src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsWithClosureController.php'):
Expand Down
5 changes: 5 additions & 0 deletions UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ release process, both versions have the same features, but Symfony 8.0 doesn't i
To upgrade, make sure to resolve all deprecation notices.
Read more about this in the [Symfony documentation](https://symfony.com/doc/8.0/setup/upgrade_major.html).

HttpClient
----------

* Remove support for amphp/http-client < 5

TwigBridge
----------

Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
"symfony/yaml": "self.version"
},
"require-dev": {
"amphp/http-client": "^4.2.1|^5.0",
"amphp/http-tunnel": "^1.0|^2.0",
"amphp/http-client": "^5.0",
"amphp/http-tunnel": "^2.0",
"async-aws/ses": "^1.0",
"async-aws/sqs": "^1.0|^2.0",
"async-aws/sns": "^1.0",
Expand Down Expand Up @@ -153,7 +153,6 @@
"psr/http-client": "^1.0",
"psr/simple-cache": "^1.0|^2.0|^3.0",
"seld/jsonlint": "^1.10",
"symfony/amphp-http-client-meta": "^1.0|^2.0",
"symfony/mercure-bundle": "^0.3",
"symfony/phpunit-bridge": "^7.4|^8.0",
"symfony/runtime": "self.version",
Expand All @@ -166,7 +165,7 @@
},
"conflict": {
"ext-psr": "<1.1|>=2",
"amphp/amp": "<2.5",
"amphp/amp": "<3",
"async-aws/core": "<1.5",
"doctrine/collections": "<1.8",
"doctrine/dbal": "<3.6",
Expand Down
42 changes: 9 additions & 33 deletions src/Symfony/Component/HttpClient/AmpHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
namespace Symfony\Component\HttpClient;

use Amp\CancelledException;
use Amp\DeferredFuture;
use Amp\Http\Client\DelegateHttpClient;
use Amp\Http\Client\InterceptedHttpClient;
use Amp\Http\Client\PooledHttpClient;
use Amp\Http\Client\Request;
use Amp\Http\HttpMessage;
use Amp\Http\Tunnel\Http1TunnelConnector;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\HttpClient\Exception\TransportException;
use Symfony\Component\HttpClient\Internal\AmpClientStateV4;
use Symfony\Component\HttpClient\Internal\AmpClientStateV5;
use Symfony\Component\HttpClient\Response\AmpResponseV4;
use Symfony\Component\HttpClient\Response\AmpResponseV5;
use Symfony\Component\HttpClient\Response\ResponseStream;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand Down Expand Up @@ -52,7 +48,7 @@ final class AmpHttpClient implements HttpClientInterface, LoggerAwareInterface,

private array $defaultOptions = self::OPTIONS_DEFAULTS;
private static array $emptyDefaults = self::OPTIONS_DEFAULTS;
private AmpClientStateV4|AmpClientStateV5 $multi;
private AmpClientStateV5 $multi;

/**
* @param array $defaultOptions Default requests' options
Expand All @@ -71,14 +67,7 @@ public function __construct(array $defaultOptions = [], ?callable $clientConfigu
[, $this->defaultOptions] = self::prepareRequest(null, null, $defaultOptions, $this->defaultOptions);
}

if (is_subclass_of(Request::class, HttpMessage::class)) {
$this->multi = new AmpClientStateV5($clientConfigurator, $maxHostConnections, $maxPendingPushes, $this->logger);
} else {
if (\PHP_VERSION_ID >= 80400) {
trigger_deprecation('symfony/http-client', '7.4', 'Using amphp/http-client < 5 is deprecated. Try running "composer require amphp/http-client:^5".');
}
$this->multi = new AmpClientStateV4($clientConfigurator, $maxHostConnections, $maxPendingPushes, $this->logger);
}
$this->multi = new AmpClientStateV5($clientConfigurator, $maxHostConnections, $maxPendingPushes, $this->logger);
}

/**
Expand Down Expand Up @@ -139,10 +128,9 @@ public function request(string $method, string $url, array $options = []): Respo
$request->addHeader($h[0], $h[1]);
}

$coef = $request instanceof HttpMessage ? 1 : 1000;
$request->setTcpConnectTimeout($coef * $options['timeout']);
$request->setTlsHandshakeTimeout($coef * $options['timeout']);
$request->setTransferTimeout($coef * $options['max_duration']);
$request->setTcpConnectTimeout($options['timeout']);
$request->setTlsHandshakeTimeout($options['timeout']);
$request->setTransferTimeout($options['max_duration']);
if (method_exists($request, 'setInactivityTimeout')) {
$request->setInactivityTimeout(0);
}
Expand All @@ -153,24 +141,16 @@ public function request(string $method, string $url, array $options = []): Respo
$request->setHeader('Authorization', 'Basic '.base64_encode(implode(':', $auth)));
}

if ($request instanceof HttpMessage) {
return new AmpResponseV5($this->multi, $request, $options, $this->logger);
}

return new AmpResponseV4($this->multi, $request, $options, $this->logger);
return new AmpResponseV5($this->multi, $request, $options, $this->logger);
}

public function stream(ResponseInterface|iterable $responses, ?float $timeout = null): ResponseStreamInterface
{
if ($responses instanceof AmpResponseV4 || $responses instanceof AmpResponseV5) {
if ($responses instanceof AmpResponseV5) {
$responses = [$responses];
}

if ($this->multi instanceof AmpClientStateV5) {
return new ResponseStream(AmpResponseV5::stream($responses, $timeout));
}

return new ResponseStream(AmpResponseV4::stream($responses, $timeout));
return new ResponseStream(AmpResponseV5::stream($responses, $timeout));
}

public function reset(): void
Expand All @@ -179,11 +159,7 @@ public function reset(): void

foreach ($this->multi->pushedResponses as $pushedResponses) {
foreach ($pushedResponses as [$pushedUrl, $pushDeferred]) {
if ($pushDeferred instanceof DeferredFuture) {
$pushDeferred->error(new CancelledException());
} else {
$pushDeferred->fail(new CancelledException());
}
$pushDeferred->fail(new CancelledException());

$this->logger?->debug(\sprintf('Unused pushed response: "%s"', $pushedUrl));
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpClient/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

8.0
---

* Remove support for amphp/http-client < 5

7.4
---

Expand Down
148 changes: 0 additions & 148 deletions src/Symfony/Component/HttpClient/Internal/AmpBodyV4.php

This file was deleted.

Loading