Open Journal Systems  3.3.0
Guzzle\Http\Curl\CurlHandle Class Reference

Public Member Functions

 __construct ($handle, $options)
 
 __destruct ()
 
 close ()
 
 getError ()
 
 getErrorNo ()
 
 getHandle ()
 
 getInfo ($option=null)
 
 getOptions ()
 
 getStderr ($asResource=false)
 
 getUrl ()
 
 isAvailable ()
 
 setErrorNo ($error)
 
 updateRequestFromTransfer (RequestInterface $request)
 

Static Public Member Functions

static factory (RequestInterface $request)
 
static parseCurlConfig ($config)
 

Data Fields

const BODY_AS_STRING = 'body_as_string'
 
const DEBUG = 'debug'
 
const PROGRESS = 'progress'
 

Protected Attributes

 $errorNo = CURLE_OK
 
 $handle
 
 $options
 

Detailed Description

Immutable wrapper for a cURL handle

Definition at line 16 of file CurlHandle.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Http\Curl\CurlHandle::__construct (   $handle,
  $options 
)

Construct a new CurlHandle object that wraps a cURL handle

Parameters
resource$handleConfigured cURL handle resource
Collection | array$optionsCurl options to use with the handle
Exceptions
InvalidArgumentException

Definition at line 243 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\$handle, and Guzzle\Http\Curl\CurlHandle\$options.

◆ __destruct()

Guzzle\Http\Curl\CurlHandle::__destruct ( )

Destructor

Definition at line 261 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\close().

Member Function Documentation

◆ close()

Guzzle\Http\Curl\CurlHandle::close ( )

Close the curl handle

Definition at line 269 of file CurlHandle.php.

Referenced by Guzzle\Http\Curl\CurlHandle\__destruct().

◆ factory()

static Guzzle\Http\Curl\CurlHandle::factory ( RequestInterface  $request)
static

Factory method to create a new curl handle based on an HTTP request.

There are some helpful options you can set to enable specific behavior:

  • debug: Set to true to enable cURL debug functionality to track the actual headers sent over the wire.
  • progress: Set to true to enable progress function callbacks.
Parameters
RequestInterface$requestRequest
Returns
CurlHandle
Exceptions
RuntimeException

Definition at line 52 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\$handle, Guzzle\Http\Message\RequestInterface\getCurlOptions(), Guzzle\Http\Message\MessageInterface\getHeader(), Guzzle\Http\Message\MessageInterface\getHeaderLines(), Guzzle\Http\Message\RequestInterface\getMethod(), Guzzle\Http\Message\RequestInterface\getPort(), Guzzle\Http\Message\RequestInterface\getProtocolVersion(), Guzzle\Http\Message\RequestInterface\getUrl(), Guzzle\Http\Message\MessageInterface\hasHeader(), Guzzle\Http\Message\MessageInterface\removeHeader(), and Guzzle\Http\Message\MessageInterface\setHeader().

Referenced by Guzzle\Http\Curl\CurlMulti\createCurlHandle(), Guzzle\Tests\Http\Curl\CurlHandleTest\testAddsCustomCurlOptions(), Guzzle\Tests\Plugin\Async\AsyncPluginTest\testAddsTimesOutAfterSending(), Guzzle\Tests\Http\Curl\CurlHandleTest\testAllowsWireTransferInfoToBeEnabled(), Guzzle\Tests\Http\Curl\CurlHandleTest\testCurlConfigurationOptionsAreSet(), Guzzle\Tests\Http\Curl\CurlHandleTest\testEnsuresRequestsHaveResponsesWhenUpdatingFromTransfer(), Guzzle\Tests\Http\Curl\CurlHandleTest\testFactoryCreatesCurlBasedOnRequest(), Guzzle\Tests\Http\Curl\CurlHandleTest\testFactoryUsesSpecifiedProtocol(), and Guzzle\Tests\Http\Curl\CurlHandleTest\testStoresStdErr().

◆ getError()

Guzzle\Http\Curl\CurlHandle::getError ( )

Get the last error that occurred on the cURL handle

Returns
string

Definition at line 292 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\isAvailable().

◆ getErrorNo()

Guzzle\Http\Curl\CurlHandle::getErrorNo ( )

Get the last error number that occurred on the cURL handle

Returns
int

Definition at line 302 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\$errorNo, and Guzzle\Http\Curl\CurlHandle\isAvailable().

◆ getHandle()

Guzzle\Http\Curl\CurlHandle::getHandle ( )

Get the wrapped curl handle

Returns
resource|null Returns the cURL handle or null if it was closed

Definition at line 385 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\isAvailable().

◆ getInfo()

Guzzle\Http\Curl\CurlHandle::getInfo (   $option = null)

Get cURL curl_getinfo data

Parameters
int$optionOption to retrieve. Pass null to retrieve all data as an array.
Returns
array|mixed

Definition at line 332 of file CurlHandle.php.

Referenced by Guzzle\Http\Curl\CurlHandle\updateRequestFromTransfer().

◆ getOptions()

Guzzle\Http\Curl\CurlHandle::getOptions ( )

Get the cURL setopt options of the handle. Changing values in the return object will have no effect on the curl handle after it is created.

Returns
Collection

Definition at line 396 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\$options.

Referenced by Guzzle\Http\Curl\CurlHandle\getStderr().

◆ getStderr()

Guzzle\Http\Curl\CurlHandle::getStderr (   $asResource = false)

Get the stderr output

Parameters
bool$asResourceSet to TRUE to get an fopen resource
Returns
string|resource|null

Definition at line 352 of file CurlHandle.php.

References Guzzle\Http\Curl\CurlHandle\getOptions().

Referenced by Guzzle\Http\Curl\CurlHandle\updateRequestFromTransfer().

◆ getUrl()

Guzzle\Http\Curl\CurlHandle::getUrl ( )

Get the URL that this handle is connecting to

Returns
Url

Definition at line 375 of file CurlHandle.php.

References Guzzle\Http\Url\factory().

◆ isAvailable()

Guzzle\Http\Curl\CurlHandle::isAvailable ( )

Check if the handle is available and still OK

Returns
bool

Definition at line 282 of file CurlHandle.php.

Referenced by Guzzle\Http\Curl\CurlHandle\getError(), Guzzle\Http\Curl\CurlHandle\getErrorNo(), and Guzzle\Http\Curl\CurlHandle\getHandle().

◆ parseCurlConfig()

static Guzzle\Http\Curl\CurlHandle::parseCurlConfig (   $config)
static

Parse the config and replace curl.* configurators into the constant based values so it can be used elsewhere

Parameters
array | Collection$configThe configuration we want to parse
Returns
array

Definition at line 457 of file CurlHandle.php.

Referenced by Guzzle\Service\Command\AbstractCommand\prepare(), Guzzle\Http\Client\prepareRequest(), and Guzzle\Tests\Http\Curl\CurlHandleTest\testParseCurlConfigConvertsStringKeysToConstantKeys().

◆ setErrorNo()

Guzzle\Http\Curl\CurlHandle::setErrorNo (   $error)

Set the curl error number

Parameters
int$errorError number to set
Returns
CurlHandle

Definition at line 318 of file CurlHandle.php.

◆ updateRequestFromTransfer()

Field Documentation

◆ $errorNo

int Guzzle\Http\Curl\CurlHandle::$errorNo = CURLE_OK
protected

CURLE_* error

Definition at line 38 of file CurlHandle.php.

Referenced by Guzzle\Http\Curl\CurlHandle\getErrorNo().

◆ $handle

resource Guzzle\Http\Curl\CurlHandle::$handle
protected

Curl resource handle

Definition at line 32 of file CurlHandle.php.

Referenced by Guzzle\Http\Curl\CurlHandle\__construct(), and Guzzle\Http\Curl\CurlHandle\factory().

◆ $options

Collection Guzzle\Http\Curl\CurlHandle::$options
protected

◆ BODY_AS_STRING

const Guzzle\Http\Curl\CurlHandle::BODY_AS_STRING = 'body_as_string'

Definition at line 18 of file CurlHandle.php.

◆ DEBUG

const Guzzle\Http\Curl\CurlHandle::DEBUG = 'debug'

Definition at line 20 of file CurlHandle.php.

◆ PROGRESS

const Guzzle\Http\Curl\CurlHandle::PROGRESS = 'progress'

Definition at line 19 of file CurlHandle.php.


The documentation for this class was generated from the following file: