/** * Class constructor * * * @param Zend_Controller_Request_Abstract $request * @param Zend_Controller_Response_Abstract $response * @param array $invokeArgs Any additional invocation arguments * @return void */ public function __construct(\Zend_Controller_Request_Abstract $request, \Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) { if ($request->isXmlHttpRequest()) { $response->setHeader('content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1', true); } parent::__construct($request, $response, $invokeArgs); }
/** * Set the neccessary headers for forcing the download dialog * * @param String $bytes The bytes that are to be downloaded * @param String $filename The filename of the downloaded file * @param Zend_Controller_Response_Abstract $response The response object * @return Void */ protected function _setHeaders($bytes, $filename, Zend_Controller_Response_Abstract $response) { // fix for IE catching or PHP bug issue $response->setHeader('Pragma', 'public'); // set expiration time $response->setHeader('Expires', '0'); // browser must download file from server instead of cache $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); // force download dialog $response->setHeader('Content-Type', 'application/octet-stream'); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. $response->setHeader('Content-Disposition', 'attachment; filename="' . basename($filename) . '"'); /* The Content-transfer-encoding header should be binary, since the file will be read directly from the disk and the raw bytes passed to the downloading computer. The Content-length header is useful to set for downloads. The browser will be able to show a progress meter as a file downloads. The content-length can be determined by filesize function returns the size of a file. */ $response->setHeader('Content-Transfer-Encoding', 'binary'); $response->setHeader('Content-Length', strlen($bytes)); }
/** * Method build response headers * * @param \Zend_Controller_Response_Abstract $response * @param array $headers * @return \Extlib\Controller\Action\Helper\File */ protected function buildHeaders(\Zend_Controller_Response_Abstract $response, array $headers) { foreach ($headers as $header => $value) { if (!in_array($header, $this->defaultHeaders)) { $response->setHeader($header, $value); } } return $this; }
/** * Hook 4: Called in $this->setResponse. * * All resources have been loaded and the $request and $response object have been created. * Theoretically this event can be triggered multiple times, but this does * not happen in a standard Zend application. * * Not initialized is the $controller object and the routing has not yet been executed. * * Previous hook: requestChanged() * Initialized since: the $this->response object * Next hook: routeStartup() * * @return void */ public function responseChanged(\Zend_Controller_Response_Abstract $response) { $response->setHeader('Expires', '', true); }