From 549930e820bb0db976fe656a302b50983650745b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 3 Jun 2019 19:56:51 +0200 Subject: [PATCH] [HttpClient] add $response->cancel() --- UPGRADE-4.4.md | 5 +++++ UPGRADE-5.0.md | 5 +++++ src/Symfony/Component/HttpClient/CHANGELOG.md | 5 +++++ .../Component/HttpClient/Response/ResponseTrait.php | 9 +++++++++ src/Symfony/Contracts/HttpClient/ResponseInterface.php | 5 +++++ 5 files changed, 29 insertions(+) diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 0e044861bd..3c5073985f 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 289910e8c2..1fd348886c 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -220,6 +220,11 @@ FrameworkBundle * Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed. * Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" 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. *