/**
  * @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();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string $directory_
  * @param boolean $global_
  *
  * @return string
  */
 public static function tmpPathName($directory_ = null, $global_ = true)
 {
     if (null === self::$m_tmpPathNameRoot) {
         static::tmpPathNameRoot();
     }
     if (!$global_) {
         if (!($sessionId = session_id())) {
             if (Runtime::isCli()) {
                 $sessionId = md5(get_current_user());
             } else {
                 $sessionId = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . date('Ymd'));
             }
         }
         if (null === $directory_) {
             return self::$m_tmpPathNameRoot . DIRECTORY_SEPARATOR . 'session' . DIRECTORY_SEPARATOR . $sessionId;
         }
         return self::$m_tmpPathNameRoot . DIRECTORY_SEPARATOR . 'session' . DIRECTORY_SEPARATOR . $sessionId . DIRECTORY_SEPARATOR . $directory_;
     }
     if (null === $directory_) {
         return self::$m_tmpPathNameRoot . DIRECTORY_SEPARATOR . 'global';
     }
     return self::$m_tmpPathNameRoot . DIRECTORY_SEPARATOR . 'global' . DIRECTORY_SEPARATOR . $directory_;
 }