Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 852fb36

Browse filesBrowse files
committed
feature #31831 [HttpClient] add $response->cancel() (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] add $response->cancel() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - (BC break allowed by the `@experimental` annotation) Canceling a response is already possible but requires registering a progress function and throwing an exception from it. This new method aims at making this much simpler. /cc @jderusse as we discussed this on Slack. Commits ------- 549930e [HttpClient] add $response->cancel()
2 parents 9ce3ff3 + 549930e commit 852fb36
Copy full SHA for 852fb36

File tree

5 files changed

+29
-0
lines changed
Filter options

5 files changed

+29
-0
lines changed

‎UPGRADE-4.4.md

Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ DependencyInjection
2525
factory: ['@factory_service', method]
2626
```
2727
28+
HttpClient
29+
----------
30+
31+
* Added method `cancel()` to `ResponseInterface`
32+
2833
Messenger
2934
---------
3035

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ FrameworkBundle
221221
* Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
222222
* Removed support for `templating` engine in `TemplateController`, use Twig instead
223223

224+
HttpClient
225+
----------
226+
227+
* Added method `cancel()` to `ResponseInterface`
228+
224229
HttpFoundation
225230
--------------
226231

‎src/Symfony/Component/HttpClient/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* added `$response->cancel()`
8+
49
4.3.0
510
-----
611

‎src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/ResponseTrait.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ public function toArray(bool $throw = true): array
169169
return $content;
170170
}
171171

172+
/**
173+
* {@inheritdoc}
174+
*/
175+
public function cancel(): void
176+
{
177+
$this->info['error'] = 'Response has been canceled.';
178+
$this->close();
179+
}
180+
172181
/**
173182
* Closes the response and all its network handles.
174183
*/

‎src/Symfony/Contracts/HttpClient/ResponseInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Contracts/HttpClient/ResponseInterface.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public function getContent(bool $throw = true): string;
7171
*/
7272
public function toArray(bool $throw = true): array;
7373

74+
/**
75+
* Cancels the response.
76+
*/
77+
public function cancel(): void;
78+
7479
/**
7580
* Returns info coming from the transport layer.
7681
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.