AppserverIo\Appserver\ServletEngine\Authenticator\FormAuthenticator::restoreRequest PHP Method

restoreRequest() protected method

Populates the passed request with the request data of the original request found in the also passed session.
protected restoreRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$session AppserverIo\Psr\Servlet\Http\HttpSessionInterface The session instance
return void
    protected function restoreRequest(HttpServletRequestInterface $servletRequest, HttpSessionInterface $session)
    {
        // query whether or not we can find the original request in the session
        if ($session->hasKey(Constants::FORM_REQUEST)) {
            // load the origin request from the session
            $req = $session->getData(Constants::FORM_REQUEST);
            // restore the original request data
            $servletRequest->setHeaders($req->headers);
            $servletRequest->setCookies($req->cookies);
            $servletRequest->setUserPrincipal($req->userPrincipal);
            $servletRequest->setServerName($req->serverName);
            $servletRequest->setQueryString($req->queryString);
            $servletRequest->setRequestUri($req->requestUri);
            $servletRequest->setDocumentRoot($req->documentRoot);
            $servletRequest->setRequestUrl($req->requestUrl);
            // set the body content if we can find one
            if ($servletRequest->getHeader(Protocol::HEADER_CONTENT_LENGTH) > 0) {
                $servletRequest->setBodyStream($req->bodyContent);
            }
        }
    }