bug #37379 [HttpClient] Support for cURL handler objects (derrabus)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] Support for cURL handler objects
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #37378
| License | MIT
| Doc PR | N/A
Commits
-------
7ccc2e1f28
[HttpClient] Support for cURL handler objects.
This commit is contained in:
commit
b3adba83fd
@ -337,7 +337,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
$this->multi->dnsCache->evictions = $this->multi->dnsCache->evictions ?: $this->multi->dnsCache->removals;
|
$this->multi->dnsCache->evictions = $this->multi->dnsCache->evictions ?: $this->multi->dnsCache->removals;
|
||||||
$this->multi->dnsCache->removals = $this->multi->dnsCache->hostnames = [];
|
$this->multi->dnsCache->removals = $this->multi->dnsCache->hostnames = [];
|
||||||
|
|
||||||
if (\is_resource($this->multi->handle)) {
|
if (\is_resource($this->multi->handle) || $this->multi->handle instanceof \CurlMultiHandle) {
|
||||||
if (\defined('CURLMOPT_PUSHFUNCTION')) {
|
if (\defined('CURLMOPT_PUSHFUNCTION')) {
|
||||||
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
|
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->multi->openHandles as [$ch]) {
|
foreach ($this->multi->openHandles as [$ch]) {
|
||||||
if (\is_resource($ch)) {
|
if (\is_resource($ch) || $ch instanceof \CurlHandle) {
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace Symfony\Component\HttpClient\Internal;
|
|||||||
*/
|
*/
|
||||||
final class CurlClientState extends ClientState
|
final class CurlClientState extends ClientState
|
||||||
{
|
{
|
||||||
/** @var resource */
|
/** @var \CurlMultiHandle|resource */
|
||||||
public $handle;
|
public $handle;
|
||||||
/** @var PushedResponse[] */
|
/** @var PushedResponse[] */
|
||||||
public $pushedResponses = [];
|
public $pushedResponses = [];
|
||||||
|
@ -36,13 +36,15 @@ final class CurlResponse implements ResponseInterface
|
|||||||
private $debugBuffer;
|
private $debugBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param \CurlHandle|resource|string $ch
|
||||||
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function __construct(CurlClientState $multi, $ch, array $options = null, LoggerInterface $logger = null, string $method = 'GET', callable $resolveRedirect = null, int $curlVersion = null)
|
public function __construct(CurlClientState $multi, $ch, array $options = null, LoggerInterface $logger = null, string $method = 'GET', callable $resolveRedirect = null, int $curlVersion = null)
|
||||||
{
|
{
|
||||||
$this->multi = $multi;
|
$this->multi = $multi;
|
||||||
|
|
||||||
if (\is_resource($ch)) {
|
if (\is_resource($ch) || $ch instanceof \CurlHandle) {
|
||||||
unset($multi->handlesActivity[(int) $ch]);
|
unset($multi->handlesActivity[(int) $ch]);
|
||||||
$this->handle = $ch;
|
$this->handle = $ch;
|
||||||
$this->debugBuffer = fopen('php://temp', 'w+');
|
$this->debugBuffer = fopen('php://temp', 'w+');
|
||||||
|
@ -50,7 +50,7 @@ trait ResponseTrait
|
|||||||
'canceled' => false,
|
'canceled' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var resource */
|
/** @var object|resource */
|
||||||
private $handle;
|
private $handle;
|
||||||
private $id;
|
private $id;
|
||||||
private $timeout = 0;
|
private $timeout = 0;
|
||||||
|
Reference in New Issue
Block a user