private function buildStreamContextOptions(ApiClient $apiClient, HttpRequest $request) {
		$options = array(
			'http' => array(),
			'ssl' => array()
		);
		if ($request->isSecureConnection()) {
			$options['ssl']['verify_host'] = true;
			$options['ssl']['allow_self_signed'] = false;
			$options['ssl']['verify_peer'] = false;

			if ($apiClient->isCertificateAuthorityCheckEnabled()) {
				$options['ssl']['verify_peer'] = true;
				$options['ssl']['cafile'] = $apiClient->getCertificateAuthority();
			}
		}
		$ipVersion = $this->readEnvironmentVariable(self::ENVIRONMENT_VARIABLE_IP_ADDRESS_VERSION);
		if ($ipVersion !== null) {
			if ($ipVersion == self::IP_ADDRESS_VERSION_V4) {
				$options['socket'] = array(
					'bindto' => '0.0.0.0:0'
				);
			} elseif ($ipVersion == self::IP_ADDRESS_VERSION_V6) {
				$options['socket'] = array(
					'bindto' => '[::]:0'
				);
			}
		}
		return $options;
	}