diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 822164d41c..364a86300d 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -25,6 +25,11 @@ DependencyInjection factory: ['@factory_service', method] ``` +HttpClient +---------- + + * Added method `cancel()` to `ResponseInterface` + Messenger --------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 72c7b28288..367a3dbc81 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -221,6 +221,11 @@ FrameworkBundle * Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead. * Removed support for `templating` engine in `TemplateController`, use Twig instead +HttpClient +---------- + + * Added method `cancel()` to `ResponseInterface` + HttpFoundation -------------- diff --git a/src/Symfony/Component/HttpClient/CHANGELOG.md b/src/Symfony/Component/HttpClient/CHANGELOG.md index 44594a71d0..005cd4a795 100644 --- a/src/Symfony/Component/HttpClient/CHANGELOG.md +++ b/src/Symfony/Component/HttpClient/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + + * added `$response->cancel()` + 4.3.0 ----- diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index 79cc40d5d8..e1777c3e12 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -169,6 +169,15 @@ trait ResponseTrait return $content; } + /** + * {@inheritdoc} + */ + public function cancel(): void + { + $this->info['error'] = 'Response has been canceled.'; + $this->close(); + } + /** * Closes the response and all its network handles. */ diff --git a/src/Symfony/Contracts/HttpClient/ResponseInterface.php b/src/Symfony/Contracts/HttpClient/ResponseInterface.php index 6751184b87..a7e01be84c 100644 --- a/src/Symfony/Contracts/HttpClient/ResponseInterface.php +++ b/src/Symfony/Contracts/HttpClient/ResponseInterface.php @@ -71,6 +71,11 @@ interface ResponseInterface */ public function toArray(bool $throw = true): array; + /** + * Cancels the response. + */ + public function cancel(): void; + /** * Returns info coming from the transport layer. *