Example #1
0
 /**
  * Initialise redirect request.
  *
  * Note that the redirect URL must be an ABSOLUTE rather than relative URL.
  * IIS under CGI mode has a bug which will crash when redirecting to
  * relative URLs.
  *
  * @param string $url  URL to redirect to
  */
 function __construct($url)
 {
     $f = new T_Filter_Xhtml();
     $content = '<html><head>' . '<meta http-equiv="Refresh" content="1;url=' . _transform($url, $f) . '">' . '</head><body>' . '<a href="' . _transform($url, $f) . '">Continue &rsaquo;</a>' . '</body></html>';
     parent::__construct(303);
     $this->setHeader("Location", $url);
     $this->setContent($content);
 }
Example #2
0
 /**
  * Pre-filter issues cache headers.
  *
  * @param T_Response $response  encapsulated response to filter
  */
 protected function doPreFilter(T_Response $response)
 {
     if ($this->cache_time <= 0) {
         $response->setHeader('Cache-Control', 'no-cache, must-revalidate');
         // HTTP/1.1 uses cache control
         $response->setHeader('Pragma', 'no-cache');
         // HTTP/1.0 uses pragma
         $expiry = time() - 60 * 60 * 24 * 30;
         // expired 30 days ago.
     } else {
         $state = "{$this->type}, max-age={$this->cache_time}, must-revalidate";
         $response->setHeader('Cache-Control', $state);
         $response->setHeader('Pragma', $this->type);
         $expiry = time() + $this->cache_time;
     }
     $date = gmdate('D, d M Y H:i:s \\G\\M\\T', $expiry);
     $response->setHeader('Expires', $date);
 }
Example #3
0
 function testisAbortedReturnTrueOnceIsAborted()
 {
     $this->response->appendFilter($this->filter[0]);
     $this->response->abort();
     $this->assertTrue($this->response->isAborted());
 }
Example #4
0
 /**
  * Error occurred and alternative response required.
  *
  * If a custom 404 response, etc. is required, this controller method
  * can be overridden to build the custom response.
  *
  * @param int $status  Status code (e.g. 404,etc)
  * @param T_Response $response  old response (to abort)
  */
 protected function respondWithStatus($status, T_Response $response)
 {
     $response->abort();
     throw $this->like('T_Response', array('status' => $status));
 }
Example #5
0
 /**
  * Adds Etag and last-modified headers to response.
  *
  * @param T_Response $response  Response to add headers to
  */
 protected function setHeader(T_Response $response)
 {
     $date = gmdate('D, d M Y H:i:s \\G\\M\\T', $this->lm);
     $response->setHeader('Last-Modified', $date);
     $response->setHeader('Etag', $this->getEtag());
 }
Example #6
0
 /**
  * Add aborted flag to abort method
  */
 function abort()
 {
     $this->is_aborted = true;
     parent::abort();
 }
Example #7
0
 /**
  * Prepare-filter forwards to get if form was present and valid.
  *
  * At this point, the request has not been sent, but has been created and is about to be.
  * If the request is valid, we want to skip out *before* the form is sent and simply
  * redirect.
  *
  * @param T_Response $response  encapsulated response to filter
  */
 protected function doPrepareFilter(T_Response $response)
 {
     if ($this->form->isPresent() && $this->form->isValid() && $this->forward) {
         // POST request is successful, therefore redirect to GET so the
         // back button cannot be used to repeat the request.
         $response->abort();
         throw new T_Response_Redirect($this->forward->getUrl());
     }
 }
Example #8
0
 /**
  * Pre-filter starts buffer.
  *
  * @param T_Response $response  encapsulated response to filter
  */
 protected function doPreFilter(T_Response $response)
 {
     $this->response = $response;
     if ($this->isZlibCompressed()) {
         return;
     }
     ob_start();
     if ($this->clientAcceptsCompression()) {
         /* Headers must be sent in the pre-filter.
            (post filter is executed after headers sent) */
         $response->setHeader('Content-Encoding', 'gzip');
     }
 }