Skip to content

Commit c5d182e

Browse files
Rokas Mikalkėnasnicolas-grekas
authored andcommitted
[HttpClient] Curl http client has to reinit curl multi handle on reset
1 parent fe90558 commit c5d182e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CurlHttpClient.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ public function reset()
360360
curl_setopt($ch, \CURLOPT_VERBOSE, false);
361361
}
362362
}
363+
364+
curl_multi_close($this->multi->handle);
365+
$this->multi->handle = curl_multi_init();
363366
}
364367

365368
/**

Tests/CurlHttpClientTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ public function testTimeoutIsNotAFatalError()
136136
parent::testTimeoutIsNotAFatalError();
137137
}
138138

139+
public function testHandleIsReinitOnReset()
140+
{
141+
$httpClient = $this->getHttpClient(__FUNCTION__);
142+
143+
$r = new \ReflectionProperty($httpClient, 'multi');
144+
$r->setAccessible(true);
145+
$clientState = $r->getValue($httpClient);
146+
$initialHandleId = (int) $clientState->handle;
147+
$httpClient->reset();
148+
self::assertNotSame($initialHandleId, (int) $clientState->handle);
149+
}
150+
139151
private function getVulcainClient(): CurlHttpClient
140152
{
141153
if (\PHP_VERSION_ID >= 70300 && \PHP_VERSION_ID < 70304) {

0 commit comments

Comments
 (0)