Requires a cookie authentication session

@param string $url Endpoint for obtaining AuthSession
@param array $options Request options

@return \Psr\Http\Message\ResponseInterface
@throws \Exception If failed request
169477
private function request($url, array $options)
    {
        $response = $this->client->request('POST', $url, $options);

        $body = $response->getBody();
        if ($response->getStatusCode() != 200
                || !isset($body)) {
            throw new \Exception('Failed request to ' . $this->endpoint . '.');
        }

        return $response;
    }
942124
public function cookie($name, $value = null, $expiry = null, array $options = [])
    {
        if (! is_null($value)) {
            return $this->addCookie($name, $value, $expiry, $options);
        }

        if ($cookie = $this->driver->manage()->getCookieNamed($name)) {
            return decrypt(rawurldecode($cookie['value']), $unserialize = false);
        }
    }
1357776
public function requestAsync($method, $url, $options)
    {
        $request = $this->authClient->getAuthenticatedRequest($method, $url, $this->getAccessToken());

        return $this->httpClient->sendAsync($request, $options);
    }
1065759
protected function executeRequest($url, array $options = array())
    {
        $ch = curl_init($url);

        foreach ($options as $name => $value) {
            if (!curl_setopt($ch, $name, $value)) {
                if ($this->logger) {
                    $this->logger->warning("Option could not be set to Curl: $name, value: $value");
                }
            }
        }

        // some options we have to force
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $results = curl_exec($ch);
        if ($results === false) {
            if ($this->logger) {
                $this->logger->error("Curl request failed: " . curl_error($ch));
            }
        }

        // close cURL resource, and free up system resources
        curl_close($ch);

        return $results;
    }
240303
public function get($url, $headers = [], $options = [])
    {
        return $this->request('GET', $url, null, $headers, $options);
    }
491006
public static function setServerLoginURL($url = '')
    {
        phpCAS :: traceBegin();
        phpCAS::_validateClientExists();

        try {
            self::$_PHPCAS_CLIENT->setServerLoginURL($url);
        } catch (Exception $e) {
            phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
        }

        phpCAS :: traceEnd();
    }
801986
public function loadFromUrl(string $url, array $options = [], CurlInterface $curl = null): Dom
    {
        if (is_null($curl)) {
            // use the default curl interface
            $curl = new Curl;
        }
        $content = $curl->get($url);

        return $this->loadStr($content, $options);
    }
535777
public function set($key, $value = null, array $options = array())
    {
        if (isset($options['expires']) && 0 > $options['expires'] && isset($this->data[$key])) {
            unset($this->data[$key]);
        } else {
            $this->data[$key] = $value;
        }

        $this->response->setCookie($key, $value, $options);

        return $this;
    }
53409
public function head($url, $options = array()) {
        $options['CURLOPT_HTTPGET'] = 0;
        $options['CURLOPT_HEADER']  = 1;
        $options['CURLOPT_NOBODY']  = 1;
        return $this->request($url, $options);
    }
1138130
private function request($method, $uri, array $options = array())
    {
        $options['auth'] = array($this->accessKey, $this->secretKey);

        return $this->httpClient->request($method, $uri, $options);
    }
410522
private function requestAPI($method, $url, array $options = [])
    {
        try {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (SessionWasExpiredException $e) {
            return $this->sendRequest((string)$method, (string)$url, $options);
        } catch (ClientException $e) {
            throw new BunqException($e);
        }
    }
625913
protected function buildRequest(string $method, string $url, array $options = []): array
    {
        if ($this->forcedAcceptJson) {
            $this->headers['accept'] = 'application/json';
        }
        if (count($this->headers) > 0) {
            if (!array_key_exists(RequestOptions::HEADERS, $options) || !is_array($options[RequestOptions::HEADERS])) {
                $options[RequestOptions::HEADERS] = [];
            }
            foreach ($this->headers as $headerName => $headerValue) {
                $options[RequestOptions::HEADERS][$headerName] = $headerValue;
            }
        }

        $options = $this->addAuthHeader($options);

        return [
            self::OPTION_METHOD => $method,
            self::OPTION_URL => $this->buildUrl($url),
            self::OPTION_OPTIONS => $options
        ];
    }
501381
protected function authenticate(Url $url)
    {
        if (
            !$url->getOption('role') ||
            !$url->getOption('firewall')
        ) {
            return $this;
        }

        $session = $this->session;
        $firewall = $url->getOption('firewall');
        $role = $url->getOption('role');
        $user = $this
            ->environmentBuilder
            ->getAuthenticationUser($url->getOption('role'));

        $token = new UsernamePasswordToken($user, null, $firewall, [$role]);
        $session->set('_security_' . $firewall, serialize($token));
        $session->save();

        $cookie = new Cookie(
            $session->getName(),
            $session->getId()
        );
        $this
            ->client
            ->getCookieJar()
            ->set($cookie);

        return $this;
    }
740640
protected function _curl($url,$options) {
		$curl=curl_init($url);
		if (!$open_basedir=ini_get('open_basedir'))
			curl_setopt($curl,CURLOPT_FOLLOWLOCATION,
				$options['follow_location']);
		curl_setopt($curl,CURLOPT_MAXREDIRS,
			$options['max_redirects']);
		curl_setopt($curl,CURLOPT_PROTOCOLS,CURLPROTO_HTTP|CURLPROTO_HTTPS);
		curl_setopt($curl,CURLOPT_REDIR_PROTOCOLS,CURLPROTO_HTTP|CURLPROTO_HTTPS);
		curl_setopt($curl,CURLOPT_CUSTOMREQUEST,$options['method']);
		if (isset($options['header']))
			curl_setopt($curl,CURLOPT_HTTPHEADER,$options['header']);
		if (isset($options['content']))
			curl_setopt($curl,CURLOPT_POSTFIELDS,$options['content']);
		if (isset($options['proxy']))
			curl_setopt($curl,CURLOPT_PROXY,$options['proxy']);
		curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
		$timeout=isset($options['timeout'])?
			$options['timeout']:
			ini_get('default_socket_timeout');
		curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout);
		curl_setopt($curl,CURLOPT_TIMEOUT,$timeout);
		$headers=[];
		curl_setopt($curl,CURLOPT_HEADERFUNCTION,
			// Callback for response headers
			function($curl,$line) use(&$headers) {
				if ($trim=trim($line))
					$headers[]=$trim;
				return strlen($line);
			}
		);
		curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,2);
		curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
		ob_start();
		curl_exec($curl);
		$err=curl_error($curl);
		curl_close($curl);
		$body=ob_get_clean();
		if (!$err &&
			$options['follow_location'] && $open_basedir &&
			preg_grep('/HTTP\/1\.\d 3\d{2}/',$headers) &&
			preg_match('/^Location: (.+)$/m',implode(PHP_EOL,$headers),$loc)) {
			$options['max_redirects']--;
			if($loc[1][0] == '/') {
				$parts=parse_url($url);
				$loc[1]=$parts['scheme'].'://'.$parts['host'].
					((isset($parts['port']) && !in_array($parts['port'],[80,443]))
						?':'.$parts['port']:'').$loc[1];
			}
			return $this->request($loc[1],$options);
		}
		return [
			'body'=>$body,
			'headers'=>$headers,
			'engine'=>'cURL',
			'cached'=>FALSE,
			'error'=>$err
		];
	}
25025
public function load($url)
    {
        $masterRequest = $this->requestStack->getMasterRequest();
        $request = Request::create($url, 'GET', array(), $masterRequest->cookies->all(), array(), $masterRequest->server->all());
        if ($masterRequest->getSession()) {
            $request->setSession($masterRequest->getSession());
        }

        $response = $this->kernel->handle($request, HttpKernelInterface::SUB_REQUEST, false);

        return $response->getContent();
    }
462684
public function start(array $options = null)
    {
        $sessionStatus = \session_status();

        if ($sessionStatus === PHP_SESSION_DISABLED) {
            throw new \RuntimeException('PHP sessions are disabled');
        }

        if ($sessionStatus === PHP_SESSION_ACTIVE) {
            throw new \RuntimeException('session has already been started');
        }

        if ($this->handler) {
            \session_set_save_handler($this->handler, true);
        }

        \session_set_cookie_params(
            $this->cookieParams['lifetime'],
            $this->cookieParams['path'],
            $this->cookieParams['domain'],
            $this->cookieParams['secure'],
            $this->cookieParams['httponly']
        );

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

        if (!isset($options['serialize_handler'])) {
            $serializeHandler = \ini_get('serialize_handler');
            if ($serializeHandler === 'php' || $serializeHandler === 'php_binary') {
                $options['serialize_handler'] = 'php_serialize';
            }
        }

        $result = \session_start($options);

        if ($result) {
            $this->moveFlash();
        }

        return $result;
    }
8680
public function post($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'POST', $params, $options);
	}