• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/httpclient.php
  • Класс: BitrixMainWebHttpClient
  • Вызов: HttpClient::__construct
public function __construct(array $options = null)
{
	$this->headers = new HttpHeaders();

	if ($options === null)
	{
		$options = [];
	}

	$defaultOptions = Configuration::getValue('http_client_options');
	if ($defaultOptions !== null)
	{
		$options += $defaultOptions;
	}

	if (!empty($options))
	{
		if (isset($options['redirect']))
		{
			$this->setRedirect($options["redirect"], $options["redirectMax"] ?? null);
		}
		if (isset($options['waitResponse']))
		{
			$this->waitResponse($options['waitResponse']);
		}
		if (isset($options['socketTimeout']))
		{
			$this->setTimeout($options['socketTimeout']);
		}
		if (isset($options['streamTimeout']))
		{
			$this->setStreamTimeout($options['streamTimeout']);
		}
		if (isset($options['version']))
		{
			$this->setVersion($options['version']);
		}
		if (isset($options['proxyHost']))
		{
			$this->setProxy($options['proxyHost'], $options['proxyPort'] ?? null, $options['proxyUser'] ?? null, $options['proxyPassword'] ?? null);
		}
		if (isset($options['compress']))
		{
			$this->setCompress($options['compress']);
		}
		if (isset($options['charset']))
		{
			$this->setCharset($options['charset']);
		}
		if (isset($options['disableSslVerification']) && $options['disableSslVerification'] === true)
		{
			$this->disableSslVerification();
		}
		if (isset($options['bodyLengthMax']))
		{
			$this->setBodyLengthMax($options['bodyLengthMax']);
		}
		if (isset($options['privateIp']))
		{
			$this->setPrivateIp($options['privateIp']);
		}
		if (isset($options['debugLevel']))
		{
			$this->setDebugLevel((int)$options['debugLevel']);
		}
		if (isset($options['cookies']))
		{
			$this->setCookies($options['cookies']);
		}
		if (isset($options['headers']))
		{
			$this->setHeaders($options['headers']);
		}
		if (isset($options['useCurl']))
		{
			$this->useCurl = (bool)$options['useCurl'];
		}
		if (isset($options['curlLogFile']))
		{
			$this->curlLogFile = $options['curlLogFile'];
		}
	}

	if ($this->useCurl && !function_exists('curl_init'))
	{
		$this->useCurl = false;
	}
}