Initiate PSR-7 request object

@return  App
198566
private function initRequest(): App
    {
        try {
            $request = ServerRequestFactory::fromGlobals();
            $this->containers()->set('request', $request);
        } catch (\InvalidArgumentException $e) {
            new Exception($e);
        }
        return $this;
    }
758124
private function _setRequest()
	{
		if ($this->_requestUri !== NULL) {
            $this->_request = preg_replace('#(^/)|(^' . ROOT . ')|(/$)#', '', $this->_requestUri);

            if (! $this->_request) {
            	$this->_request = self::DEFAULT_MODULE . '/' . self::DEFAULT_VIEW;
            }

            $this->_requestVars = explode('/', $this->_request);
            if (count($this->_requestVars) == 1) {
				$this->_request       .= '/' . self::DEFAULT_VIEW;
				$this->_requestVars[]  = self::DEFAULT_VIEW;
            }

            return $this;
        }

        throw new Exception('Request URI is not available');
	}
14743
def app(environ, start_response):
    """"""
    r = HttpRequestHandler(environ, start_response, Router).dispatch()
    return r
1233846
public function getRequest()
    {
        if (null == $this->request) {
            $this->setRequest(Application::container()->get('request'));
        }
        return $this->request;
    }
906539
public static function initRequest()
    {
        global $PPHP;

        $parsedURL = parse_url($_SERVER['REQUEST_URI']);
        self::$_PATH = dejoin('/', trim($parsedURL['path'], '/'));
        while (count(self::$_PATH) > 0 && self::$_PATH[0] === '') {
            array_shift(self::$_PATH);
        };

        // Eat up initial directory as language if it's 2 characters
        $lang = $PPHP['config']['global']['default_lang'];
        if (isset(self::$_PATH[0]) && strlen(self::$_PATH[0]) === 2) {
            $lang = strtolower(array_shift(self::$_PATH));
        };
        self::$_req['lang'] = $lang;
        self::$_req['default_lang'] = $PPHP['config']['global']['default_lang'];
        self::$_req['base'] = ($lang === $PPHP['config']['global']['default_lang'] ? '' : "/{$lang}");

        // Eat up initial directories as long as they contain request flags
        self::$_req['binary'] = false;
        while (count(self::$_PATH) > 0 && self::$_PATH[0][0] === '=') {
            $flag = strtolower(array_shift(self::$_PATH));
            if ($flag === '=bin') {
                self::$_req['binary'] = true;
            };
        };

        self::$_req['path'] = implode('/', self::$_PATH);
        self::$_req['query'] = (isset($parsedURL['query']) ? '?' . $parsedURL['query'] : '');
        self::$_req['host'] = $_SERVER['HTTP_HOST'];
        self::$_req['remote_addr'] = self::_remoteIP();
        self::$_req['ssl']
            = (
                (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
                ||
                (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
                ||
                (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
                ||
                (isset($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on')
            );
        self::$_req['get'] = $_GET;
        self::$_req['post'] = $_POST;

        foreach (array('get', 'post') as $method) {
            if (isset(self::$_req[$method]['__arrays'])) {
                foreach (self::$_req[$method]['__arrays'] as $key) {
                    if (!isset(self::$_req[$method][$key])) {
                        self::$_req[$method][$key] = array();
                    } elseif (!is_array(self::$_req[$method][$key])) {
                        self::$_req[$method][$key] = array(self::$_req[$method][$key]);
                    };
                };
            };
        };

        // Process file uploads
        self::$_req['files'] = array();
        if (isset($_FILES) && count($_FILES) > 0) {
            $finfo = finfo_open(FILEINFO_MIME_TYPE);
            foreach ($_FILES as $key => $info) {
                if (is_uploaded_file($info['tmp_name'])) {
                    self::$_req['files'][$key] = $info;
                    // Overwrite client's MIME Type with server's determination
                    self::$_req['files'][$key]['type'] = finfo_file($finfo, $info['tmp_name']);
                    foreach (pathinfo($info['name']) as $pik => $piv) {
                        self::$_req['files'][$key][$pik] = $piv;
                    };
                };
            };
            finfo_close($finfo);
        };

        self::_initCommon();
    }
46616
function request()
    {
        if (!$this->request) {
            $request = new HttpRequest( new BuildHttpRequest );
            $this->request = $request;
        }

        return $this->request;
    }
1047688
public static function startup()
    {
        global $PPHP;

        trigger('language', self::$_req['lang']);

        if (isset(self::$_PATH[1]) && listeners('route/' . self::$_PATH[0] . '+' . self::$_PATH[1])) {
            self::$_base = array_shift(self::$_PATH) . '+' . array_shift(self::$_PATH);
        } elseif (isset(self::$_PATH[0])) {
            if (listeners('route/' . self::$_PATH[0])) {
                self::$_base = array_shift(self::$_PATH);
            } else {
                trigger('http_status', 404);
            };
        } elseif (listeners('route/main')) {
            self::$_base = 'main';
        } else {
            trigger('http_status', 404);
        };
        self::$_req['path_args'] = self::$_PATH;
    }
1299347
protected function initiateSubRequest()
    {
        if (!$this->controller instanceof AbstractWidgetController) {
            if (isset($this->controller)) {
                throw new MissingControllerException('initiateSubRequest() can not be called if there is no valid controller extending TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetController. Got "' . get_class($this->controller) . '" in class "' . get_class($this) . '".', 1289422564);
            }
            throw new MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add a corresponding injectController method to your WidgetViewHelper class "' . get_class($this) . '".', 1284401632);
        }
            /** @var $subRequest \ApacheSolrForTypo3\Solr\Widget\WidgetRequest */
        $subRequest = $this->objectManager->get(SolrFluidWidgetRequest::class);
        $subRequest->setWidgetContext($this->widgetContext);

        $this->passArgumentsToSubRequest($subRequest);
        $subResponse = $this->objectManager->get(Response::class);
        $this->controller->processRequest($subRequest, $subResponse);
        return $subResponse;
    }
722655
protected function createDefaultRequest()
    {
        $request = Request::createFromGlobals();
        $session = new Session();

        $request->setSession($session);

        return $request;
    }
580687
public function requestAccessToken()
    {
        try {
            $this->session->requestAccessToken($_GET['code']);
            return $this;
        } catch (Exception $e) {
            $this->redirectToSpotifyAuthorizeUrl();
        }
    }
586652
protected function _buildRequest()
    {
        $this->_request = $this->_factory
            ->getNewCancelBuildRequest($this->_api, $this->_order)
            ->build();
        return $this;
    }
1304555
protected function application()
    {
        // Initialize the Silex Application
        $applicationInitializer = new ApplicationInitializer;

        $app = $applicationInitializer->initialize();

        // Set the default services
        $defaultServices = new \Synapse\Application\Services;
        $defaultServices->register($app);

        // Set the application-specific services
        $appServices = new \Application\Services;
        $appServices->register($app);

        return $app;
    }
122196
protected function initiateSubRequest()
    {
        $objectManager = new ObjectManager();
        $this->controller = $objectManager->get(PaginateController::class);

        return parent::initiateSubRequest();
    }
392185
protected function buildPDFRequest()
    {
        return (new Request(
            $this->getApplication(),
            $this->buildPDFURL(),
            Request::METHOD_GET
        ))->setHeader(
            Request::HEADER_ACCEPT,
            Request::CONTENT_TYPE_PDF
        );
    }
157144
public function launchAction()
    {
        self::$obLevel = ob_get_level();
        
        if (php_sapi_name() != 'cli') {
            ob_start();
        }
        
        $router = $this->_router;
        $activeRoute = $router->getActiveRoute();
        
        // optionally sets the content-type
        if (isset($activeRoute['contentType'])) {
            $this->_response->setContentType($activeRoute['contentType']);
        }
        
        // optionally sets the client cache duration
        if (isset($activeRoute['cacheMinutes'])) {
            $this->_response->setCacheable($activeRoute['cacheMinutes']);
        }
        
        // flag to allow the code of the controller to be executed
        // or not if a middleware returns false
        $allowedByPreMiddleware = true;

         // handle CORS using the cors built-in middleware
        $corsPreflight = new \Nf\Middleware\Cors();
        $allowedByPreMiddleware = $corsPreflight->execute();

        // call pre middlewares defined by the active route
        if (isset($activeRoute['middlewaresPre'])) {
            foreach ($activeRoute['middlewaresPre'] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
            unset($middleware);
        }
        // call pre middlewares defined programatically
        if (isset($this->registeredMiddlewares[self::MIDDLEWARE_PRE])) {
            foreach ($this->registeredMiddlewares[self::MIDDLEWARE_PRE] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
        }
        
        if ($allowedByPreMiddleware) {
            // call the action
            call_user_func(array(
                $this->_controllerInstance,
                $this->_actionName . 'Action'
            ));
            $content = ob_get_clean();
            $this->_response->addBodyPart($content);
            
            // call post middlewares
            if (isset($activeRoute['middlewaresPost'])) {
                foreach ($activeRoute['middlewaresPost'] as $middleware) {
                    $object = new $middleware();
                    $object->execute();
                }
                unset($middleware);
            }
            // call post middlewares defined programatically, by instance
            if (isset($this->registeredMiddlewares[self::MIDDLEWARE_POST])) {
                foreach ($this->registeredMiddlewares[self::MIDDLEWARE_POST] as $middleware) {
                    $middleware->execute();
                }
            }
        }
      
    }
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;
    }
72333
protected function createHttpRequest()
	{
		$protocol = (isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] === 'on') ? HttpRequest::PROTOCOL_HTTPS : HttpRequest::PROTOCOL_HTTP;
		$uri = StringUtils::startsWith($_SERVER['REQUEST_URI'], '/index.php')?StringUtils::afterFirst($_SERVER['REQUEST_URI'], '/index.php'):$_SERVER['REQUEST_URI'];

		$subFolder = StringUtils::afterFirst(getcwd(), $_SERVER['DOCUMENT_ROOT']);
		$cleanPath = StringUtils::between($uri, $subFolder, '?');

		$languages = array();
		$langsRates = explode(',', isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null);

		foreach($langsRates as $lr) {
			$lrParts = explode(';', $lr);

			$languages[$lrParts[0]] = isset($lrParts[1])?(float)StringUtils::afterFirst($lrParts[1], 'q='):1.0;
		}

		$requestTime = new \DateTime();
		$requestTime->setTimestamp($_SERVER['REQUEST_TIME']);

		$httpRequest = new HttpRequest();

		$httpRequest->setHost($_SERVER['SERVER_NAME']);
		$httpRequest->setPath($cleanPath);
		$httpRequest->setPort($_SERVER['SERVER_PORT']);
		$httpRequest->setProtocol($protocol);
		$httpRequest->setQuery($_SERVER['QUERY_STRING']);
		$httpRequest->setURI($uri);

		$httpRequest->setRequestTime($requestTime);
		$httpRequest->setRequestMethod($_SERVER['REQUEST_METHOD']);
		$httpRequest->setUserAgent(isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null);
		$httpRequest->setLanguages($languages);
		$httpRequest->setAcceptLanguage(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:null);
		$httpRequest->setRemoteAddress($_SERVER['REMOTE_ADDR']);
		$httpRequest->setReferrer(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);

		return $httpRequest;
	}