52 CURLOPT_URL => (string)$uri,
53 CURLOPT_HEADER =>
false,
54 CURLOPT_RETURNTRANSFER =>
false,
55 CURLOPT_FOLLOWLOCATION =>
false,
56 CURLOPT_HTTP_VERSION => (
$request->getProtocolVersion() ===
'1.1' ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0),
57 CURLOPT_CONNECTTIMEOUT => (
int)($options[
'socketTimeout'] ?? 30),
58 CURLOPT_LOW_SPEED_TIME => (
int)($options[
'streamTimeout'] ?? 60),
59 CURLOPT_LOW_SPEED_LIMIT => 1,
63 if (isset($options[
'contextOptions'][
'ssl'][
'verify_peer']))
65 $curlOptions[CURLOPT_SSL_VERIFYPEER] = (bool)$options[
'contextOptions'][
'ssl'][
'verify_peer'];
67 if (isset($options[
'contextOptions'][
'ssl'][
'verify_peer_name']))
69 $curlOptions[CURLOPT_SSL_VERIFYHOST] = $options[
'contextOptions'][
'ssl'][
'verify_peer_name'] ? 2 : 0;
73 if ($method ===
'HEAD')
75 $curlOptions[CURLOPT_NOBODY] =
true;
79 $curlOptions[CURLOPT_CUSTOMREQUEST] = $method;
82 if (isset($options[
'effectiveIp']) && $options[
'effectiveIp'] instanceof
IpAddress)
85 $curlOptions[CURLOPT_RESOLVE] = [$uri->getHost() .
':' . $uri->getPort() .
':' . $options[
'effectiveIp']];
88 if (isset($options[
'proxyHost']))
90 $curlOptions[CURLOPT_PROXY] = (string)$options[
'proxyHost'];
92 if (isset($options[
'proxyPort']))
94 $curlOptions[CURLOPT_PROXYPORT] = (int)$options[
'proxyPort'];
98 if ($method !=
'GET' && $method !=
'HEAD' && $method !=
'TRACE')
101 $size = $body->getSize();
105 if ($body->isSeekable())
110 $curlOptions[CURLOPT_UPLOAD] =
true;
114 $curlOptions[CURLOPT_INFILESIZE] = $size;
117 $curlOptions[CURLOPT_READFUNCTION] = [$this,
'readRequestBody'];
121 $curlOptions[CURLOPT_HEADERFUNCTION] = [$this,
'receiveHeaders'];
123 $curlOptions[CURLOPT_WRITEFUNCTION] = [$this,
'receiveBody'];
125 if (!empty($options[
'curlLogFile']))
127 $this->logFileHandle = fopen($options[
'curlLogFile'],
'a+');
129 $curlOptions[CURLOPT_VERBOSE] =
true;
132 curl_setopt_array($this->handle, $curlOptions);