8000 [HttpClient] fix collecting debug info on destruction of CurlResponse · symfony/symfony@f0b52c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0b52c8

Browse files
[HttpClient] fix collecting debug info on destruction of CurlResponse
1 parent 09e0a6e commit f0b52c8

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,15 @@ public function getContent(bool $throw = true): string
225225

226226
public function __destruct()
227227
{
228-
curl_setopt($this->handle, \CURLOPT_VERBOSE, false);
228+
try {
229+
if (null === $this->timeout) {
230+
return; // Unused pushed response
231+
}
229232

230-
if (null === $this->timeout) {
231-
return; // Unused pushed response
233+
$this->doDestruct();
234+
} finally {
235+
curl_setopt($this->handle, \CURLOPT_VERBOSE, false);
232236
}
233-
234-
$this->doDestruct();
235237
}
236238

237239
/**

src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,16 @@ public function testHandleIsRemovedOnException()
167167
$this->assertCount(0, $clientState->openHandles);
168168
}
169169
}
170+
171+
public function testDebugInfoOnDestruct()
172+
{
173+
$client = $this->getHttpClient(__FUNCTION__);
174+
175+
$traceInfo = [];
176+
$client->request('GET', 'http://localhost:8057', ['on_progress' => function (int $dlNow, int $dlSize, array $info) use (&$traceInfo) {
177+
$traceInfo = $info;
178+
}]);
179+
180+
$this->assertNotEmpty($traceInfo['debug']);
181+
}
170182
}

0 commit comments

Comments
 (0)
0