/** * @param \Components\Uri $uri_ */ public function dispatch(Uri $uri_, $method_ = null) { ob_start(); try { $this->dispatchImpl($uri_, $method_); } catch (\Exception $e) { if (Runtime::isCli()) { throw $e; } Runtime::addException($e); if ($e instanceof Http_Exception) { $e->sendHeader(); } } // FIXME Why?? if (Runtime::isCli()) { echo ob_get_clean(); } else { ob_flush(); /** * Do not corrupt output for other mimetypes - assuming: * - Exceptions are logged * - Debug output & exceptions are sent via headers * * Visualization happens via client side / logging or * custom implementations of http/scriptlet#dispatch. */ if (false === Io_Mimetype::TEXT_HTML()->equals($this->getResponse()->getMimetype())) { Debug::clear(); Runtime::clearExceptions(); } if (session_id()) { session_write_close(); } } }