/**
  * Populates the passed request with the request data of the original request
  * found in the also passed session.
  *
  * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The servlet request instance
  * @param \AppserverIo\Psr\Servlet\Http\HttpSessionInterface        $session        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);
         }
     }
 }