request = $request; return $this; } public function getRequest() { return $this->request; } public function getHeaders() { $headers = array(); if (!$this->frameable) { $headers[] = array('X-Frame-Options', 'Deny'); } return $headers; } public function setCacheDurationInSeconds($duration) { $this->cacheable = $duration; return $this; } public function setLastModified($epoch_timestamp) { $this->lastModified = $epoch_timestamp; return $this; } public function setHTTPResponseCode($code) { $this->responseCode = $code; return $this; } public function getHTTPResponseCode() { return $this->responseCode; } public function setFrameable($frameable) { $this->frameable = $frameable; return $this; } public function getCacheHeaders() { $headers = array(); if ($this->cacheable) { $headers[] = array( 'Expires', $this->formatEpochTimestampForHTTPHeader(time() + $this->cacheable)); } else { $headers[] = array( 'Cache-Control', 'private, no-cache, no-store, must-revalidate'); $headers[] = array( 'Expires', 'Sat, 01 Jan 2000 00:00:00 GMT'); } if ($this->lastModified) { $headers[] = array( 'Last-Modified', $this->formatEpochTimestampForHTTPHeader($this->lastModified)); } return $headers; } private function formatEpochTimestampForHTTPHeader($epoch_timestamp) { return gmdate('D, d M Y H:i:s', $epoch_timestamp).' GMT'; } abstract public function buildResponseString(); }