Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit596dcc3

Browse files
bug#49926 [HttpClient] Fix canceling MockResponse (fancyweb)
This PR was merged into the 5.4 branch.Discussion----------[HttpClient] Fix canceling MockResponse| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | -| Tickets |#49925| License | MIT| Doc PR | -MockResponse not issued by MockHttpClient might not have the http_method info set.http_code looks safe since it's defined in the constructor.Commits-------f9abba7 [HttpClient] Fix canceling MockResponse
2 parentsad7f2e4 +f9abba7 commit596dcc3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function cancel(): void
112112
}
113113

114114
$onProgress =$this->requestOptions['on_progress'] ??staticfunction () {};
115-
$dlSize =isset($this->headers['content-encoding']) ||'HEAD' ===$this->info['http_method'] ||\in_array($this->info['http_code'], [204,304],true) ?0 : (int) ($this->headers['content-length'][0] ??0);
115+
$dlSize =isset($this->headers['content-encoding']) ||'HEAD' ===($this->info['http_method'] ??null) ||\in_array($this->info['http_code'], [204,304],true) ?0 : (int) ($this->headers['content-length'][0] ??0);
116116
$onProgress($this->offset,$dlSize,$this->info);
117117
}
118118

‎src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public function testResetsRequestCount()
507507
$this->assertSame(0,$client->getRequestsCount());
508508
}
509509

510-
publicfunctiontestCancellingMockResponseExecutesOnProgressWithUpdatedInfo()
510+
publicfunctiontestCancelingMockResponseExecutesOnProgressWithUpdatedInfo()
511511
{
512512
$client =newMockHttpClient(newMockResponse(['foo','bar','ccc']));
513513
$canceled =false;

‎src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,12 @@ public function testErrorIsTakenIntoAccountInInitialization()
116116
'error' =>'ccc error',
117117
]))->getStatusCode();
118118
}
119+
120+
publicfunctiontestCancelingAMockResponseNotIssuedByMockHttpClient()
121+
{
122+
$mockResponse =newMockResponse();
123+
$mockResponse->cancel();
124+
125+
$this->assertTrue($mockResponse->getInfo('canceled'));
126+
}
119127
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp