PHP Class VCR\Util\CurlHelper

ファイルを表示 Open project: php-vcr/php-vcr Class Usage Examples

Public Methods

Method Description
getCurlOptionFromResponse ( Response $response, integer $option ) : mixed Returns a cURL option from a Response.
handleOutput ( Response $response, array $curlOptions, resource $ch ) : null | string Outputs a response depending on the set cURL option.
setCurlOptionOnRequest ( Request $request, integer $option, mixed $value, resource $curlHandle = null ) Sets a cURL option on a Request.
validateCurlPOSTBody ( Request $request, resource $curlHandle = null ) Makes sure we've properly handled the POST body, such as ensuring that CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set.

Method Details

getCurlOptionFromResponse() public static method

Returns a cURL option from a Response.
public static getCurlOptionFromResponse ( Response $response, integer $option ) : mixed
$response VCR\Response Response to get cURL option from.
$option integer cURL option to get.
return mixed Value of the cURL option.

handleOutput() public static method

The response body can be written to a file, returned, echoed or passed to a custom function. The response header might be passed to a custom function.
public static handleOutput ( Response $response, array $curlOptions, resource $ch ) : null | string
$response VCR\Response Response which contains the response body.
$curlOptions array cURL options which are not stored within the Response.
$ch resource cURL handle to add headers if needed.
return null | string

setCurlOptionOnRequest() public static method

Sets a cURL option on a Request.
public static setCurlOptionOnRequest ( Request $request, integer $option, mixed $value, resource $curlHandle = null )
$request VCR\Request Request to set cURL option to.
$option integer cURL option to set.
$value mixed Value of the cURL option.
$curlHandle resource cURL handle where this option is set on (optional).

validateCurlPOSTBody() public static method

Makes sure we've properly handled the POST body, such as ensuring that CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set.
public static validateCurlPOSTBody ( Request $request, resource $curlHandle = null )
$request VCR\Request Request to set cURL option to.
$curlHandle resource cURL handle associated with the request.