Skip to content

Commit c453b1b

Browse files
committed
bug #31850 [HttpClient] add $response->cancel() (nicolas-grekas)
This PR was merged into the 4.3 branch. Discussion ---------- [HttpClient] add $response->cancel() | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#11668 An alternative to #31845 and #31842. Same as #31831 but considered as a bug fix (at the Contracts level), thus for 4.3. I think we're early enough since 4.3/1.1 to do it. That will save us some headaches in the short term. Commits ------- c402418723 [HttpClient] add $response->cancel()
2 parents 7640431 + e7e2261 commit c453b1b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Response/ResponseTrait.php

Lines 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
*/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": "^7.1.3",
2323
"psr/log": "^1.0",
24-
"symfony/http-client-contracts": "^1.1",
24+
"symfony/http-client-contracts": "^1.1.3",
2525
"symfony/polyfill-php73": "^1.11"
2626
},
2727
"require-dev": {

0 commit comments

Comments
 (0)