Constructs a Psr7 compliant request for use in a Psr7 client.

@return \Psr\Http\Message\RequestInterface
769560
public function toPsrRequest(): RequestInterface {
        return new Psr7Request(
            $this->method,
            $this->getUri(),
            $this->Headers->toPsr7Array(),
            isset($this->body) ? new Psr7Stream($this->body) : null
        );
    }
722655
protected function createDefaultRequest()
    {
        $request = Request::createFromGlobals();
        $session = new Session();

        $request->setSession($session);

        return $request;
    }
114718
public function getRequest()
	{
	    $name = 'web.request';
	    if (!Ioc::has($name)) {
	        Ioc::setShared($name, function(){
	            return Request::createFromGlobals($_SERVER);
	        });
	    }
	    
	    return Ioc::get($name);
	}
40868
public function buildAuthnRequest()
    {
        $authnRequest = (new AuthnRequest())
            ->setAssertionConsumerServiceURL($this->getMetadata()->getFirstAcs()->getLocation())
            ->setProtocolBinding($this->getMetadata()->getFirstAcs()->getBinding())
            ->setID(Helper::generateID())
            ->setIssueInstant(new \DateTime())
            ->setDestination($this->getMetadata()->getFirstSso()->getLocation())
            ->setIssuer(new Issuer($this->getMetadata()->getServiceProvider()->getEntityID()))
            ->setRelayState(Helper::generateID());

        if ($this->getMetadata()->getFirstIdpSsoDescriptor()->getWantAuthnRequestsSigned()) {
            $authnRequest->setSignature(
                new SignatureWriter(
                    $this->getMetadata()
                        ->getFirstSpSsoDescriptor()
                        ->getFirstKeyDescriptor(KeyDescriptor::USE_SIGNING)
                        ->getCertificate(),
                    KeyHelper::createPrivateKey($this->getPrivateKey(), '')
                )
            );
        }

        return $authnRequest;
    }
1255158
protected function resolveRequestHandler(): RequestHandlerInterface
    {
        if ($this->preselectedRequestHandlerClassName !== null && isset($this->requestHandlers[$this->preselectedRequestHandlerClassName])) {
            /** @var RequestHandlerInterface $requestHandler */
            $requestHandler = $this->requestHandlers[$this->preselectedRequestHandlerClassName];
            if ($requestHandler->canHandleRequest()) {
                return $requestHandler;
            }
        }

        /** @var RequestHandlerInterface $requestHandler */
        foreach ($this->requestHandlers as $requestHandler) {
            if ($requestHandler->canHandleRequest() > 0) {
                $priority = $requestHandler->getPriority();
                if (isset($suitableRequestHandlers[$priority])) {
                    throw new FlowException('More than one request handler with the same priority can handle the request, but only one handler may be active at a time!', 1176475350);
                }
                $suitableRequestHandlers[$priority] = $requestHandler;
            }
        }
        if (empty($suitableRequestHandlers)) {
            throw new FlowException('No suitable request handler could be found for the current request. This is most likely a setup-problem, so please check your composer.json and/or try removing Configuration/PackageStates.php', 1464882543);
        }
        ksort($suitableRequestHandlers);
        return array_pop($suitableRequestHandlers);
    }
962782
protected function makeRequest()
    {
        $requestType = trim(strtolower($this->getService('type')));
        if($this->getService('endpoint'))
            $this->requestUrl->appendPathSegment($this->getEndpoint());
        if($requestType != 'post' && $this->getParam())
            $this->requestUrl->setQueryFromArray($this->getParam());
        $this->requestUrl->setQueryParameter('key',$this->getApiKey());
        switch ($requestType){
            case 'POST':
                $postData = json_encode($this->getParam());
                break;
            case 'GET':
            default:
                break;
        }
        $request        = StreamClient::make()->{$requestType}($this->requestUrl->write());
        $responseBody   = $this->unserializeResponse($request->getBody());
        $responseStatus = $request->getStatusCode();
        switch($responseStatus){
            case 200:
                if($responseBody['status'] != self::STATUS_SUCCESS)
                    throw new \ErrorException($responseBody['status'].':'.$responseBody['error_message']);
                break;
            default:
                throw new \ErrorException($responseStatus.' '.$request->getReasonPhrase().':'.$responseBody['error_message']);
        }
        $checkClass = __NAMESPACE__."\Services\\".ucfirst($this->service);
        $this->responseBody = (Arr::has($responseBody,$this->getService(self::$responseKey))) ? Arr::get($responseBody,$this->getService(self::$responseKey)) : $responseBody;
        return (class_exists($checkClass)) ? new $checkClass($this) : $responseBody;
    }
1146157
public function request($url, array $params = array())
    {
        $uri = $this->makeUri($url, $params);

        return new Psr7\Request('get', $uri);
    }
46616
function request()
    {
        if (!$this->request) {
            $request = new HttpRequest( new BuildHttpRequest );
            $this->request = $request;
        }

        return $this->request;
    }
34740
public function createRequest(string $method, $uri): RequestInterface
  {
    $request = new Request($method, $uri);

    \logger()->debug('Created PSR-7 Request("'.$method.'","'.$uri.'"") (Guzzle)');

    return $request;
  }
42430
public function getRequest(): ?Request
    {
        if (!$this->hasRequest()) {
            $this->setRequest($this->getDefaultRequest());
        }
        return $this->request;
    }
343179
protected function requestProcessor()
    {
        $components = $this->builder->components();

        $processors     = $components->processors();
        $httpProcessors = $components->httpProcessors();

        return $processors->chain(array(
            $httpProcessors->parseBody(),
            $this->parseRouteProcessor(),
            $httpProcessors->buildRequest()
        ));
    }
1359719
public function getRequest(): RequestInterface
    {
        if (!$this->request) {
            $this->resolveOptions();
            $this->request = $this->createRequest();
        }

        return parent::getRequest();
    }
1196758
public function send(): ResponseInterface
    {
        $client = new HttpClient(['base_uri' => $this->url]);

        return $client->get(
            $this->getUrlPath(),
            [
                'query' => $this->getParams(),
            ]
        );
    }
731286
public function createHandler()
    {
        $this->pushHeaderMiddleware(
            function (RequestInterface $request) {
                return $request->withHeader('User-Agent', Pay::CLIENT . ' v' . Pay::VERSION);
            }
        );

        $this->pushBasicAuthMiddleware(
            function (RequestInterface $request) {
                return $request->withHeader(
                    'Authorization', 'Basic ' . base64_encode(
                        $this->config->getClientId() . ':' . $this->config->getClientSecret()
                    )
                );
            }
        );

        $this->pushRetryMiddleware(self::decider(), self::delay());

        return $this->stack;
    }
113767
public function createRequest()
    {
        $this->crt = new SignedCertificate();
        $this->crt->setPrivateKey(openssl_pkey_new($this->certConfigure));

        $privKey = $this->crt->getPrivateKey();
        $this->crt->setCsr(openssl_csr_new($this->domainName()->get(), $privKey, $this->certConfigure));

        $request = json_encode([
            'csr' => $this->crt->getCsr()
        ]);

        // Send CSR to server and wait for signing
        $response = $this->signWithServer($request);
        $response = json_decode($response);
        $this->crt->setSignedCert(openssl_x509_read($response->certificate));

        return $this;
    }
1289852
public function build(): RequestCacheNamesRequest
	{
		$instance = new RequestCacheNamesRequest();
		if ($this->securityOrigin === null) {
			throw new BuilderException('Property [securityOrigin] is required.');
		}
		$instance->securityOrigin = $this->securityOrigin;
		return $instance;
	}
511816
public function upload()
    {
        $multipartStream = new Psr7\MultipartStream([
            [
                'name' => 'metadata',
                'headers' => ['Content-Type' => 'application/json; charset=UTF-8'],
                'contents' => $this->jsonEncode($this->metadata)
            ],
            [
                'name' => 'data',
                'headers' => ['Content-Type' => $this->contentType],
                'contents' => $this->data
            ]
        ], 'boundary');

        $headers = [
            'Content-Type' => 'multipart/related; boundary=boundary',
            'Content-Length' => $multipartStream->getSize()
        ];

        return $this->jsonDecode(
            $this->requestWrapper->send(
                new Request(
                    'POST',
                    $this->uri,
                    $headers,
                    $multipartStream
                ),
                $this->requestOptions
            )->getBody(),
            true
        );
    }