/** * Set the server also for all registered handlers * * @see Aspamia_Http_Server_Handler_Abstract::setServer() */ public function setServer(Aspamia_Http_Server $server) { parent::setServer($server); foreach ($this->_routes as $handler) { $handler->setServer($server); } }
/** * Overload setConfig to make sure some config options are OK * * @param Zend_Config | array $config */ public function setConfig($config) { parent::setConfig($config); if (!is_array($this->_config['directory_index'])) { if (strlen($this->_config['directory_index'])) { $this->_config['directory_index'] = array($this->_config['directory_index']); } else { $this->_config['directory_index'] = array(); } } if (!is_array($this->_config['mime_types'])) { require_once 'Aspamia/Http/Server/Handler/Exception.php'; throw new Aspamia_Http_Server_Handler_Exception("MIME type configuration must be an array"); } }
protected function _handle($connection) { // Read and parse the HTTP request line $this->_callPreRequestPlugins($connection); $request = $this->_readRequest($connection); $this->_callPostRequestPlugins($request); $response = $this->_handler->handle($request); $this->_callPreResponsePlugins($response); $serverSignature = 'Aspamia/' . self::ASPAMIA_VERSION . ' ' . 'PHP/' . PHP_VERSION; $response->setHeader(array('Server' => $serverSignature, 'Date' => date(DATE_RFC1123))); // TODO: Right now only 'close' is working, make keep-alive work too. $response->setHeader('connection', 'close'); fwrite($connection, (string) $response); fclose($conn); $this->_callPostResponsePlugins($connection); }