original_string: public function prerenderPage(MvcEvent $event)
      {
          $originalRequest = $event->getRequest();
  
          if (!$this->shouldPrerenderPage($originalRequest)) {
              return;
          }
  
          $event->stopPropagation(true);
          $eventManager = $this->getEventManager();
  
          // Trigger a pre-event (for creating a response from cache, for instance)
          $responses = $eventManager->trigger(PrerenderEvent::EVENT_PRERENDER_PRE, new PrerenderEvent($originalRequest));
  
          if ($responses->last() instanceof HttpResponse) {
              return $responses->last();
          }
  
          // Make the actual request to Prerender service
          $client    = $this->getHttpClient();
          $uri       = rtrim($this->moduleOptions->getPrerenderUrl(), '/') . '/' . $originalRequest->getUriString();
          $userAgent = $originalRequest->getHeaders()->get('User-Agent')->getFieldValue();
  
          $client->setUri($uri)
                 ->setMethod(HttpRequest::METHOD_GET);
  
          $request = $client->getRequest();
          $request->getHeaders()->addHeaderLine('User-Agent', $userAgent)
                                ->addHeaderLine('Accept-Encoding', 'gzip');
  
          if ($prerenderToken = $this->moduleOptions->getPrerenderToken()) {
              $request->getHeaders()->addHeaderLine('X-Prerender-Token', $prerenderToken);
          }
  
          $response = $client->send($request);
  
          // Trigger a post-event (for putting in cache the response, for instance)
          $prerenderEvent = new PrerenderEvent($request, $response);
          $eventManager->trigger(PrerenderEvent::EVENT_PRERENDER_POST, $prerenderEvent);
  
          return $prerenderEvent->getResponse();
      }
code: public function prerenderPage(MvcEvent $event)
      {
          $originalRequest = $event->getRequest();
  
          if (!$this->shouldPrerenderPage($originalRequest)) {
              return;
          }
  
          $event->stopPropagation(true);
          $eventManager = $this->getEventManager();
  
          // Trigger a pre-event (for creating a response from cache, for instance)
          $responses = $eventManager->trigger(PrerenderEvent::EVENT_PRERENDER_PRE, new PrerenderEvent($originalRequest));
  
          if ($responses->last() instanceof HttpResponse) {
              return $responses->last();
          }
  
          // Make the actual request to Prerender service
          $client    = $this->getHttpClient();
          $uri       = rtrim($this->moduleOptions->getPrerenderUrl(), '/') . '/' . $originalRequest->getUriString();
          $userAgent = $originalRequest->getHeaders()->get('User-Agent')->getFieldValue();
  
          $client->setUri($uri)
                 ->setMethod(HttpRequest::METHOD_GET);
  
          $request = $client->getRequest();
          $request->getHeaders()->addHeaderLine('User-Agent', $userAgent)
                                ->addHeaderLine('Accept-Encoding', 'gzip');
  
          if ($prerenderToken = $this->moduleOptions->getPrerenderToken()) {
              $request->getHeaders()->addHeaderLine('X-Prerender-Token', $prerenderToken);
          }
  
          $response = $client->send($request);
  
          // Trigger a post-event (for putting in cache the response, for instance)
          $prerenderEvent = new PrerenderEvent($request, $response);
          $eventManager->trigger(PrerenderEvent::EVENT_PRERENDER_POST, $prerenderEvent);
  
          return $prerenderEvent->getResponse();
      }
code_tokens: public function prerenderPage ( MvcEvent $ event ) { $ originalRequest = $ event -> getRequest ( ) ; if ( ! $ this -> shouldPrerenderPage ( $ originalRequest ) ) { return ; } $ event -> stopPropagation ( true ) ; $ eventManager = $ this -> getEventManager ( ) ; // Trigger a pre-event (for creating a response from cache, for instance) $ responses = $ eventManager -> trigger ( PrerenderEvent :: EVENT_PRERENDER_PRE , new PrerenderEvent ( $ originalRequest ) ) ; if ( $ responses -> last ( ) instanceof HttpResponse ) { return $ responses -> last ( ) ; } // Make the actual request to Prerender service $ client = $ this -> getHttpClient ( ) ; $ uri = rtrim ( $ this -> moduleOptions -> getPrerenderUrl ( ) , '/' ) . '/' . $ originalRequest -> getUriString ( ) ; $ userAgent = $ originalRequest -> getHeaders ( ) -> get ( 'User-Agent' ) -> getFieldValue ( ) ; $ client -> setUri ( $ uri ) -> setMethod ( HttpRequest :: METHOD_GET ) ; $ request = $ client -> getRequest ( ) ; $ request -> getHeaders ( ) -> addHeaderLine ( 'User-Agent' , $ userAgent ) -> addHeaderLine ( 'Accept-Encoding' , 'gzip' ) ; if ( $ prerenderToken = $ this -> moduleOptions -> getPrerenderToken ( ) ) { $ request -> getHeaders ( ) -> addHeaderLine ( 'X-Prerender-Token' , $ prerenderToken ) ; } $ response = $ client -> send ( $ request ) ; // Trigger a post-event (for putting in cache the response, for instance) $ prerenderEvent = new PrerenderEvent ( $ request , $ response ) ; $ eventManager -> trigger ( PrerenderEvent :: EVENT_PRERENDER_POST , $ prerenderEvent ) ; return $ prerenderEvent -> getResponse ( ) ; }
docstring: Pre-render the page
  
  @param  MvcEvent $event
  @return void|ResponseInterface
docstring_tokens: Pre - render the page