CurlFactory
in package
implements
CurlFactoryInterface
Creates curl resources from a request
Tags
Table of Contents
Interfaces
Constants
- CURL_VERSION_STR = 'curl_version'
- LOW_CURL_VERSION_NUMBER = '7.21.2'
Properties
- $handles : array<string|int, resource>|array<string|int, CurlHandle>
- $maxHandles : int
Methods
- __construct() : mixed
- __destruct() : mixed
- create() : EasyHandle
- Creates a cURL handle resource.
- finish() : PromiseInterface
- Completes a cURL transaction, either returning a response promise or a rejected promise.
- release() : void
- Release an easy handle, allowing it to be reused or closed.
- applyBody() : void
- applyHandlerOptions() : void
- applyHeaders() : void
- applyMethod() : void
- createHeaderFn() : callable
- createRejection() : PromiseInterface
- finishError() : PromiseInterface
- getCurlVersion() : string
- getDefaultConf() : array<int|string, mixed>
- invokeStats() : void
- removeHeader() : void
- Remove a header from the options array.
- retryFailedRewind() : PromiseInterface
- This function ensures that a response was set on a transaction. If one was not set, then the request is retried if possible. This error typically means you are sending a payload, curl encountered a "Connection died, retrying a fresh connect" error, tried to rewind the stream, and then encountered a "necessary data rewind wasn't possible" error, causing the request to be sent through curl_multi_info_read() without an error status.
- sanitizeCurlError() : string
- supportsHttp2() : bool
- supportsTls12() : bool
- supportsTls13() : bool
Constants
CURL_VERSION_STR
public
mixed
CURL_VERSION_STR
= 'curl_version'
LOW_CURL_VERSION_NUMBER
public
mixed
LOW_CURL_VERSION_NUMBER
= '7.21.2'
Properties
$handles
private
array<string|int, resource>|array<string|int, CurlHandle>
$handles
= []
$maxHandles
private
int
$maxHandles
Total number of idle handles to keep in cache
Methods
__construct()
public
__construct(int $maxHandles) : mixed
Parameters
- $maxHandles : int
-
Maximum number of idle handles.
__destruct()
public
__destruct() : mixed
create()
Creates a cURL handle resource.
public
create(RequestInterface $request, array<string|int, mixed> $options) : EasyHandle
Parameters
- $request : RequestInterface
-
Request
- $options : array<string|int, mixed>
-
Transfer options
Return values
EasyHandlefinish()
Completes a cURL transaction, either returning a response promise or a rejected promise.
public
static finish(callable(RequestInterface, array<string|int, mixed>): PromiseInterface $handler, EasyHandle $easy, CurlFactoryInterface $factory) : PromiseInterface
Parameters
- $handler : callable(RequestInterface, array<string|int, mixed>): PromiseInterface
- $easy : EasyHandle
- $factory : CurlFactoryInterface
-
Dictates how the handle is released
Return values
PromiseInterfacerelease()
Release an easy handle, allowing it to be reused or closed.
public
release(EasyHandle $easy) : void
This function must call unset on the easy handle's "handle" property.
Parameters
- $easy : EasyHandle
applyBody()
private
applyBody(RequestInterface $request, array<string|int, mixed> $options, array<string|int, mixed> &$conf) : void
Parameters
- $request : RequestInterface
- $options : array<string|int, mixed>
- $conf : array<string|int, mixed>
applyHandlerOptions()
private
applyHandlerOptions(EasyHandle $easy, array<string|int, mixed> &$conf) : void
Parameters
- $easy : EasyHandle
- $conf : array<string|int, mixed>
applyHeaders()
private
applyHeaders(EasyHandle $easy, array<string|int, mixed> &$conf) : void
Parameters
- $easy : EasyHandle
- $conf : array<string|int, mixed>
applyMethod()
private
applyMethod(EasyHandle $easy, array<string|int, mixed> &$conf) : void
Parameters
- $easy : EasyHandle
- $conf : array<string|int, mixed>
createHeaderFn()
private
createHeaderFn(EasyHandle $easy) : callable
Parameters
- $easy : EasyHandle
Return values
callablecreateRejection()
private
static createRejection(EasyHandle $easy, array<string|int, mixed> $ctx) : PromiseInterface
Parameters
- $easy : EasyHandle
- $ctx : array<string|int, mixed>
Return values
PromiseInterfacefinishError()
private
static finishError(callable(RequestInterface, array<string|int, mixed>): PromiseInterface $handler, EasyHandle $easy, CurlFactoryInterface $factory) : PromiseInterface
Parameters
- $handler : callable(RequestInterface, array<string|int, mixed>): PromiseInterface
- $easy : EasyHandle
- $factory : CurlFactoryInterface
Return values
PromiseInterfacegetCurlVersion()
private
static getCurlVersion() : string
Return values
stringgetDefaultConf()
private
getDefaultConf(EasyHandle $easy) : array<int|string, mixed>
Parameters
- $easy : EasyHandle
Return values
array<int|string, mixed>invokeStats()
private
static invokeStats(EasyHandle $easy) : void
Parameters
- $easy : EasyHandle
removeHeader()
Remove a header from the options array.
private
removeHeader(string $name, array<string|int, mixed> &$options) : void
Parameters
- $name : string
-
Case-insensitive header to remove
- $options : array<string|int, mixed>
-
Array of options to modify
retryFailedRewind()
This function ensures that a response was set on a transaction. If one was not set, then the request is retried if possible. This error typically means you are sending a payload, curl encountered a "Connection died, retrying a fresh connect" error, tried to rewind the stream, and then encountered a "necessary data rewind wasn't possible" error, causing the request to be sent through curl_multi_info_read() without an error status.
private
static retryFailedRewind(callable(RequestInterface, array<string|int, mixed>): PromiseInterface $handler, EasyHandle $easy, array<string|int, mixed> $ctx) : PromiseInterface
Parameters
- $handler : callable(RequestInterface, array<string|int, mixed>): PromiseInterface
- $easy : EasyHandle
- $ctx : array<string|int, mixed>
Return values
PromiseInterfacesanitizeCurlError()
private
static sanitizeCurlError(string $error, UriInterface $uri) : string
Parameters
- $error : string
- $uri : UriInterface
Return values
stringsupportsHttp2()
private
static supportsHttp2() : bool
Return values
boolsupportsTls12()
private
static supportsTls12() : bool
Return values
boolsupportsTls13()
private
static supportsTls13() : bool