• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/http/socket/handler.php
  • Класс: BitrixMainWebHttpSocketHandler
  • Вызов: Handler::createSocket
protected function createSocket(array $options): Stream
{
	$proxyHost = (string)($options['proxyHost'] ?? '');
	$proxyPort = (int)($options['proxyPort'] ?? 80);
	$contextOptions = $options['contextOptions'] ?? [];

	$uri = $this->request->getUri();

	if ($proxyHost != '')
	{
		$host = $proxyHost;
		$port = $proxyPort;

		// set original host to match a sertificate for proxy tunneling
		$contextOptions['ssl']['peer_name'] = $uri->getHost();
	}
	else
	{
		$host = $uri->getHost();
		$port = $uri->getPort();

		if (isset($options['effectiveIp']) && $options['effectiveIp'] instanceof IpAddress)
		{
			// set original host to match a sertificate
			$contextOptions['ssl']['peer_name'] = $host;

			// resolved in HttpClient if private IPs were disabled
			$host = $options['effectiveIp']->get();
		}
	}

	$socket = new Stream(
		'tcp://' . $host . ':' . $port,
		[
			'socketTimeout' => $options['socketTimeout'] ?? null,
			'streamTimeout' => $options['streamTimeout'] ?? null,
			'contextOptions' => $contextOptions,
		]
	);

	return $socket;
}