getCurlOption() public method

public getCurlOption ( $key ) : mixed
$key
return mixed
Example #1
0
 /**
  * Makes sure we've properly handled the POST body, such as ensuring that
  * CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set.
  *
  * @param Request  $request Request to set cURL option to.
  * @param resource $curlHandle cURL handle associated with the request.
  */
 public static function validateCurlPOSTBody(Request $request, $curlHandle = null)
 {
     $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION);
     if (is_null($readFunction)) {
         return;
     }
     // Guzzle 4 sometimes sets the post body in CURLOPT_POSTFIELDS even if
     // they have already set CURLOPT_READFUNCTION.
     if ($request->getBody()) {
         return;
     }
     $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE);
     Assertion::notEmpty($bodySize, "To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.");
     $body = call_user_func_array($readFunction, array($curlHandle, fopen('php://memory', 'r'), $bodySize));
     $request->setBody($body);
 }