Returns the request handler (if any) which is currently handling the request.
public getActiveRequestHandler ( ) : Neos\Flow\Core\RequestHandlerInterface | ||
return | Neos\Flow\Core\RequestHandlerInterface |
/** * @return Domain */ public function findOneByActiveRequest() { $matchingDomain = null; $activeRequestHandler = $this->bootstrap->getActiveRequestHandler(); if ($activeRequestHandler instanceof HttpRequestHandlerInterface) { $matchingDomain = $this->findOneByHost($activeRequestHandler->getHttpRequest()->getUri()->getHost(), true); } return $matchingDomain; }
/** * Sends the given HTTP request * * @param Http\Request $httpRequest * @return Http\Response * @throws Http\Exception * @api */ public function sendRequest(Http\Request $httpRequest) { $requestHandler = $this->bootstrap->getActiveRequestHandler(); if (!$requestHandler instanceof FunctionalTestRequestHandler) { throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749); } $this->securityContext->clearContext(); $this->validatorResolver->reset(); $response = new Http\Response(); $componentContext = new ComponentContext($httpRequest, $response); $requestHandler->setComponentContext($componentContext); $objectManager = $this->bootstrap->getObjectManager(); $baseComponentChain = $objectManager->get(\Neos\Flow\Http\Component\ComponentChain::class); $componentContext = new ComponentContext($httpRequest, $response); try { $baseComponentChain->handle($componentContext); } catch (\Throwable $throwable) { $this->prepareErrorResponse($throwable, $componentContext->getHttpResponse()); } catch (\Exception $exception) { $this->prepareErrorResponse($exception, $componentContext->getHttpResponse()); } $session = $this->bootstrap->getObjectManager()->get(SessionInterface::class); if ($session->isStarted()) { $session->close(); } $this->persistenceManager->clearState(); return $componentContext->getHttpResponse(); }
/** * Sets up a virtual browser and web environment for seamless HTTP and MVC * related tests. * * @return void */ protected function setupHttp() { $this->browser = new \Neos\Flow\Http\Client\Browser(); $this->browser->setRequestEngine(new \Neos\Flow\Http\Client\InternalRequestEngine()); $this->router = $this->browser->getRequestEngine()->getRouter(); $this->router->setRoutesConfiguration(null); $requestHandler = self::$bootstrap->getActiveRequestHandler(); $request = Request::create(new \Neos\Flow\Http\Uri('http://localhost/typo3/flow/test')); $componentContext = new ComponentContext($request, new \Neos\Flow\Http\Response()); $requestHandler->setComponentContext($componentContext); }
/** * Returns TRUE if there is a session that can be resumed. * * If a to-be-resumed session was inactive for too long, this function will * trigger the expiration of that session. An expired session cannot be resumed. * * NOTE that this method does a bit more than the name implies: Because the * session info data needs to be loaded, this method stores this data already * so it doesn't have to be loaded again once the session is being used. * * @return boolean * @api */ public function canBeResumed() { if ($this->request === null) { $this->initializeHttpAndCookie($this->bootstrap->getActiveRequestHandler()); } if ($this->sessionCookie === null || $this->request === null || $this->started === true) { return false; } $sessionMetaData = $this->metaDataCache->get($this->sessionCookie->getValue()); if ($sessionMetaData === false) { return false; } $this->lastActivityTimestamp = $sessionMetaData['lastActivityTimestamp']; $this->storageIdentifier = $sessionMetaData['storageIdentifier']; $this->tags = $sessionMetaData['tags']; return !$this->autoExpire(); }
/** * Detects and returns the website's absolute base URI * * @return string The resolved resource base URI, @see getResourcesBaseUri() * @throws TargetException if the baseUri can't be resolved */ protected function detectResourcesBaseUri() { if ($this->baseUri !== '' && ($this->baseUri[0] === '/' || strpos($this->baseUri, '://') !== false)) { return $this->baseUri; } $requestHandler = $this->bootstrap->getActiveRequestHandler(); if ($requestHandler instanceof HttpRequestHandlerInterface) { return $requestHandler->getHttpRequest()->getBaseUri() . $this->baseUri; } if ($this->httpBaseUri === null) { throw new TargetException(sprintf('The base URI for resources could not be detected. Please specify the "Neos.Flow.http.baseUri" setting or use an absolute "baseUri" option for target "%s".', $this->name), 1438093977); } return $this->httpBaseUri . $this->baseUri; }