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).
示例#1
0
 /**
  * Set an option for a cURL transfer.
  *
  * @link http://www.php.net/manual/en/function.curl-setopt.php
  * @param resource $curlHandle A cURL handle returned by curl_init().
  * @param integer  $option     The CURLOPT_XXX option to set.
  * @param mixed    $value      The value to be set on option.
  *
  * @return boolean  Returns TRUE on success or FALSE on failure.
  */
 public static function curlSetopt($curlHandle, $option, $value)
 {
     CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value, $curlHandle);
     static::$curlOptions[(int) $curlHandle][$option] = $value;
     return \curl_setopt($curlHandle, $option, $value);
 }
示例#2
0
 public function testSetCurlOptionReadFunction()
 {
     $expected = 'test body';
     $request = new Request('POST', 'example.com');
     $test = $this;
     $callback = function ($curlHandle, $fileHandle, $size) use($test, $expected) {
         $test->assertInternalType('resource', $curlHandle);
         $test->assertInternalType('resource', $fileHandle);
         $test->assertEquals(strlen($expected), $size);
         return $expected;
     };
     CurlHelper::setCurlOptionOnRequest($request, CURLOPT_INFILESIZE, strlen($expected));
     CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, $callback, curl_init());
     $this->assertEquals($expected, $request->getBody());
 }