Lines Matching refs:options
29 $options = $this->getDefaultOptions($request, $headers);
30 $this->applyMethod($request, $options);
33 $this->applyHandlerOptions($request, $options);
36 $this->applyHeaders($request, $options);
37 unset($options['_headers']);
39 // Add handler options from the request's configuration options
41 $options = $this->applyCustomCurlOptions(
43 $options
51 $body = $this->getOutputBody($request, $options);
52 curl_setopt_array($handle, $options);
138 private function getOutputBody(array $request, array &$options)
141 if (isset($options[CURLOPT_WRITEFUNCTION])) {
145 if (isset($options[CURLOPT_FILE])) {
146 return $options[CURLOPT_FILE];
151 return $options[CURLOPT_FILE] = fopen('php://temp', 'w+');
162 $options = [
185 $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
187 $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
189 $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
194 $options[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
197 return $options;
200 private function applyMethod(array $request, array &$options)
203 $this->applyBody($request, $options);
212 $options[CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
216 $options[CURLOPT_NOBODY] = true;
218 $options[CURLOPT_WRITEFUNCTION],
219 $options[CURLOPT_READFUNCTION],
220 $options[CURLOPT_FILE],
221 $options[CURLOPT_INFILE]
226 private function applyBody(array $request, array &$options)
237 $options[CURLOPT_POSTFIELDS] = Core::body($request);
239 $this->removeHeader('Content-Length', $options);
240 $this->removeHeader('Transfer-Encoding', $options);
242 $options[CURLOPT_UPLOAD] = true;
245 $options[CURLOPT_INFILESIZE] = $size;
246 $this->removeHeader('Content-Length', $options);
248 $this->addStreamingBody($request, $options);
253 $options[CURLOPT_HTTPHEADER][] = 'Expect:';
258 $options[CURLOPT_HTTPHEADER][] = 'Content-Type:';
262 private function addStreamingBody(array $request, array &$options)
267 $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
270 if (!isset($options[CURLOPT_INFILESIZE])) {
272 $options[CURLOPT_INFILESIZE] = $size;
276 $options[CURLOPT_INFILE] = $body;
279 $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body, &$buf) {
293 private function applyHeaders(array $request, array &$options)
295 foreach ($options['_headers'] as $name => $values) {
297 $options[CURLOPT_HTTPHEADER][] = "$name: $value";
303 $options[CURLOPT_HTTPHEADER][] = 'Accept:';
308 * Takes an array of curl options specified in the 'curl' option of a
309 * request's configuration array and maps them to CURLOPT_* options.
314 * @param array $options Array of existing curl options
316 * @return array Returns a new array of curl options
318 private function applyCustomCurlOptions(array $config, array $options)
327 return $curlOptions + $options;
331 * Remove a header from the options array.
334 * @param array $options Array of options to modify
336 private function removeHeader($name, array &$options)
338 foreach (array_keys($options['_headers']) as $key) {
340 unset($options['_headers'][$key]);
347 * Applies an array of request client options to a the options array.
352 private function applyHandlerOptions(array $request, array &$options)
360 unset($options[CURLOPT_CAINFO]);
361 $options[CURLOPT_SSL_VERIFYHOST] = 0;
362 $options[CURLOPT_SSL_VERIFYPEER] = false;
366 $options[CURLOPT_SSL_VERIFYHOST] = 2;
367 $options[CURLOPT_SSL_VERIFYPEER] = true;
370 $options[CURLOPT_CAINFO] = $value;
387 $options[CURLOPT_ENCODING] = $accept;
389 $options[CURLOPT_ENCODING] = '';
391 $options[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
409 $options[CURLOPT_WRITEFUNCTION] =
414 $options[CURLOPT_FILE] = $value;
424 $options[CURLOPT_TIMEOUT_MS] = $value * 1000;
426 $options[CURLOPT_TIMEOUT] = $value;
433 $options[CURLOPT_CONNECTTIMEOUT_MS] = $value * 1000;
435 $options[CURLOPT_CONNECTTIMEOUT] = $value;
442 $options[CURLOPT_PROXY] = $value;
446 $options[CURLOPT_PROXY] = $value[$scheme];
454 $options[CURLOPT_SSLCERTPASSWD] = $value[1];
464 $options[CURLOPT_SSLCERT] = $value;
470 $options[CURLOPT_SSLKEYPASSWD] = $value[1];
480 $options[CURLOPT_SSLKEY] = $value;
491 $options[CURLOPT_NOPROGRESS] = false;
492 $options[CURLOPT_PROGRESSFUNCTION] =
506 $options[CURLOPT_STDERR] = Core::getDebugResource($value);
507 $options[CURLOPT_VERBOSE] = true;