Perform the NTLM authenticated post against one of the chosen
endpoints.

@param string $url
URL to try posting to.
@param integer $timeout
Number of seconds before the request should timeout.
@return boolean
552898
public function doNTLMPost($url, $timeout = 6)
    {
        $this->reset();

        $ch = curl_init();
        $opts = array(
            CURLOPT_URL             => $url,
            CURLOPT_HTTPAUTH        => CURLAUTH_BASIC | CURLAUTH_NTLM,
            CURLOPT_CUSTOMREQUEST   => 'POST',
            CURLOPT_POSTFIELDS      => $this->getAutoDiscoverRequest(),
            CURLOPT_RETURNTRANSFER  => true,
            CURLOPT_USERPWD         => $this->username . ':' . $this->password,
            CURLOPT_TIMEOUT         => $timeout,
            CURLOPT_CONNECTTIMEOUT  => $this->connection_timeout,
            CURLOPT_FOLLOWLOCATION  => true,
            CURLOPT_HEADER          => false,
            CURLOPT_HEADERFUNCTION  => array($this, 'readHeaders'),
            CURLOPT_IPRESOLVE       => CURL_IPRESOLVE_V4,
            CURLOPT_SSL_VERIFYPEER  => true,
            CURLOPT_SSL_VERIFYHOST  => 2,
        );

        // Set the appropriate content-type.
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8'));

        if (!empty($this->cainfo)) {
            $opts[CURLOPT_CAINFO] = $this->cainfo;
        }

        if (!empty($this->capath)) {
            $opts[CURLOPT_CAPATH] = $this->capath;
        }

        if ($this->skip_ssl_verification) {
            $opts[CURLOPT_SSL_VERIFYPEER] = false;
        }

        curl_setopt_array($ch, $opts);
        $this->last_response    = curl_exec($ch);
        $this->last_info        = curl_getinfo($ch);
        $this->last_curl_errno  = curl_errno($ch);
        $this->last_curl_error  = curl_error($ch);

        if ($this->last_curl_errno != CURLE_OK) {
            return false;
        }

        $discovered = $this->parseAutodiscoverResponse();

        return $discovered;
    }
112388
public function waitForAlert($timeout = 60)
	{
		$result = FALSE;
		$i = 0;
		do
		{
			sleep(1);
			try
			{
				$result = $this->alertText();
			}
			catch (\RuntimeException $e)
			{
				;
			}
		} while (++$i < $timeout && $result === FALSE);
		return $result;
	}
1292402
public function recv($timeout = null)
    {
        // timeout specified?
        if ($timeout !== null) {
            stream_set_timeout($this->socket, $timeout);
        }
        // retrieve response
        $line = fgets($this->socket, 1024);

        if ($this->validationOptions['debug'] === true) {
            $this->debug[] = ["timestamp" => microtime(true), "message" => "received> {$line}"];
        }

        // have we timed out?
        $info = stream_get_meta_data($this->socket);
        if (!empty($info['timed_out'])) {
            throw new Exception\ExceptionTimeout('Timed out in recv');
        }
        // did we actually receive anything?
        if ($line === false) {
            throw new Exception\ExceptionNoResponse('No response in recv');
        }

        return $line;
    }
1356364
protected function recv($timeout = null)
        {
            if (!$this->connected()) {
                throw new Exception('No connection');
            }
            // timeout specified?
            if ($timeout !== null) {
                stream_set_timeout($this->socket, $timeout);
            }
            // retrieve response
            $line = fgets($this->socket, 1024);
            $this->debug('<<<recv: ' . $line);
            // have we timed out?
            $info = stream_get_meta_data($this->socket);
            if (!empty($info['timed_out'])) {
                throw new Exception('Timed out in recv');
            }
            // did we actually receive anything?
            if ($line === false) {
                throw new Exception('No response in recv');
            }
            return $line;
        }
322768
public static function doPost($url, $post_data = [], $timeout = 5, $header = "", $data_type = "")
    {
        if (empty($url) || empty($post_data) || empty($timeout))
            return false;
        if (!preg_match('/^(http|https)/is', $url))
            $url = "http://" . $url;
        $code = self::getSupport();
        switch ($code) {
            case 1:
                return self::curlPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 2:
                return self::socketPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 3:
                return self::phpPost($url, $post_data, $timeout, $header, $data_type);
                break;
            default:
                return false;
        }
    }
1298833
public function goDnsLookup($url = '', $timeout = 0, $headers = [])
    {
        if (!empty($headers)) {
            $this->setHeaders($headers);
        }

        if (!empty($url)) {
            $this->urlData = self::parseUrl($url);
        }

        if ($timeout) {
            $this->dnsTimeout = $timeout;
        }

        $ip = Client::getDnsCache($this->urlData['host']);
        if ($ip !== null) {
            $this->client = $this->getHttpClient($this->urlData['host'], $ip, $this->urlData['port'], $this->urlData['ssl']);

            $headers = array_merge($headers, [
                'Host'        => $this->urlData['host'],
                'X-Ngx-LogId' => $this->getContext()->getLogId(),
                'Accept-Encoding' => 'gzip,deflate'
            ]);
            $this->setHeaders($headers);
            return $this;
        } else {
            return $this->getObject(Dns::class, [$this, $this->dnsTimeout, $headers]);
        }
    }
885572
protected function _sendRawGet($url, $timeout = FALSE)
	{
		$httpTransport = $this->getHttpTransport();

		$httpResponse = $httpTransport->performGetRequest($url, $timeout);
		$solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays);

		if ($solrResponse->getHttpStatus() != 200)
		{
			throw new Apache_Solr_HttpTransportException($solrResponse);
		}

		return $solrResponse;
	}
1327635
public function wait($timeout = 60)
    {
        $timeoutMicro = $timeout !== null ? microtime(true) + (float)$timeout : null;
        while ($this->isRunning()) {
            if ($timeout !== null && microtime(true) >= $timeoutMicro) {
                return null;
            }
            usleep(1000);
        }

        return $this->getExitCode();
    }
1067573
public function connect($timeout = null)
    {
        if ($timeout === null) {
            $timeout = intval(ini_get('default_socket_timeout'));
        }

        $this->timeout      = $timeout;
        $this->streamSocket = $this->getStream(
            $this->options->getAddress(), $timeout, $this->options->getStreamContext());
        $this->setStreamTimeout($timeout);

        $infoResponse = $this->receive();

        if ($this->isErrorResponse($infoResponse) === true) {
            throw Exception::forFailedConnection($infoResponse);
        } else {
            $this->processServerInfo($infoResponse);
            if ($this->serverInfo->isTLSRequired()) {
                set_error_handler(
                    function ($errno, $errstr, $errfile, $errline) {
                        restore_error_handler();
                        throw Exception::forFailedConnection($errstr);
                    });

                if (!stream_socket_enable_crypto(
                        $this->streamSocket, true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT)) {
                    throw Exception::forFailedConnection('Error negotiating crypto');
                }

                restore_error_handler();
            }
        }

        $msg = 'CONNECT '.$this->options;
        $this->send($msg);
        $this->ping();
        $pingResponse = $this->receive();

        if ($this->isErrorResponse($pingResponse) === true) {
            throw Exception::forFailedPing($pingResponse);
        }
    }
1071636
public static function validateUrl($url, $timeout=5) {
    $urlParts = @parse_url($url);
    // check local relative url
    if (empty($urlParts["host"])) {
      $fh = @fopen($url, "r");
      return ($fh !== false);
    }

    // check remote url
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    $r = curl_exec($ch);
    $headers = split("\n", $r);

    preg_match('/.+ ([0-9]{3}) .+/', $headers[0], $matches);
    return (intval($matches[1]) < 400);
  }
1145880
public static function UrlExsist ($url, $timeout = 30, $protocol_version = self::VERSION_1_1) {
		$result = static::HeadRequest($url, $timeout, $protocol_version);
		return isset($result['http']['status']['code']) && $result['http']['status']['code'] !== '404';
	}
1333686
public function socketSelect($timeout = 1)
    {
        if (!isset($this->queue)) {
            throw new Exception('You need to call socketPerform() before.');
        }
        return $this->queue->socketSelect($timeout);
    }
802455
public function setTimeout($timeout)
    {
        curl_setopt($this->curl, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, $timeout);
    }
747524
public function setConnectionTimeout($timeout)
    {
        ValidationUtility::ensureInteger('$timeout', $timeout);

        if ($timeout < 0)
        {
            throw new \InvalidArgumentException('The given timeout value is negative.');
        }

        $this->connectionTimeout = $timeout;

        return $this;
    }
461211
public function enable(string $name, int $timeout = 0)
    {
        return $this->curl->post($this->base_url.'/'.$name.'/enable?'.http_build_query([
                    'timeout' => $timeout,
                ]
            )
        );
    }
1184096
public static function reqByCurlSSLPost($params, $url, $timeout = 10, $sslCertPath = null, $sslKeyPath = null) {
        return QpayMchUtil::_reqByCurl($params, $url, $timeout, $sslCertPath, $sslKeyPath);
    }
820434
public static function phpGet($url, $timeout = 5, $header = "")
    {
        $header = empty($header) ? self::defaultHeader() : $header;
        $opts = [
            'http' => [
                'protocol_version' => '1.0', //http协议版本(若不指定php5.2系默认为http1.0)
                'method' => "GET", //获取方式
                'timeout' => $timeout, //超时时间
                'header' => $header
            ]
        ];
        $context = stream_context_create($opts);
        return @file_get_contents($url, false, $context);
    }