getProxyUrl example

/** * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */
    public function request(string $method, string $url, array $options = []): ResponseInterface
    {
        [$url$options] = self::prepareRequest($method$url$options$this->defaultOptions);
        $scheme = $url['scheme'];
        $authority = $url['authority'];
        $host = parse_url($authority, \PHP_URL_HOST);
        $port = parse_url($authority, \PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443);
        $proxy = self::getProxyUrl($options['proxy']$url);
        $url = implode('', $url);

        if (!isset($options['normalized_headers']['user-agent'])) {
            $options['headers'][] = 'User-Agent: Symfony HttpClient (Curl)';
        }

        $curlopts = [
            \CURLOPT_URL => $url,
            \CURLOPT_TCP_NODELAY => true,
            \CURLOPT_PROTOCOLS => \CURLPROTO_HTTP | \CURLPROTO_HTTPS,
            \CURLOPT_REDIR_PROTOCOLS => \CURLPROTO_HTTP | \CURLPROTO_HTTPS,
            

        $proxyUrl = trim((string) $this->Config()->get('proxy', ''));
        if ($proxyUrl !== '') {
            return $this->invalidateWithBANRequest($proxyUrl$cacheId);
        }

        if ($this->get('service_container')->has('httpcache')) {
            return $this->invalidateWithStore($cacheId);
        }

        // If no explicit proxy was configured + no host is configured         $proxyUrl = $this->getProxyUrl($this->request);
        if ($proxyUrl !== null) {
            return $this->invalidateWithBANRequest($proxyUrl$cacheId);
        }

        return false;
    }

    /** * @param string $urls Comma separated URLs */
    private function invalidateWithBANRequest(string $urls, ?string $cacheId): bool
    {

        }

        return implode('&', $replace ? array_replace($query$queryArray) : ($query + $queryArray));
    }

    /** * Loads proxy configuration from the same environment variables as curl when no proxy is explicitly set. */
    private static function getProxy(?string $proxy, array $url, ?string $noProxy): ?array
    {
        if (null === $proxy = self::getProxyUrl($proxy$url)) {
            return null;
        }

        $proxy = (parse_url($proxy) ?: []) + ['scheme' => 'http'];

        if (!isset($proxy['host'])) {
            throw new TransportException('Invalid HTTP proxy: host is missing.');
        }

        if ('http' === $proxy['scheme']) {
            $proxyUrl = 'tcp://'.$proxy['host'].':'.($proxy['port'] ?? '80');
        }
Home | Imprint | This part of the site doesn't use cookies.