Esempio n. 1
0
        $this->services[$name] = function () use($closure) {
            static $instance;
            if (null === $instance) {
                $instance = $closure();
            }
            return $instance;
        };
    }
}
class _Headers
{
    public function header($key, $value = null)
    {
        header($this->_header($key, $value));
    }
    /**
     * Output an HTTP header. If $value is null, $key is
     * assume to be the HTTP response code, and the ":"
     * separator will be omitted.
     */
    public function _header($key, $value = null)
    {
        if (null === $value) {
            return $key;
        }
        $key = str_replace(' ', '-', ucwords(str_replace('-', ' ', $key)));
        return "{$key}: {$value}";
    }
}
_Request::$_headers = _Response::$_headers = new _Headers();
Esempio n. 2
0
<?php

require_once dirname(dirname(__FILE__)) . '/klein.php';
class HeadersEcho extends _Headers
{
    public function header($key, $value = null)
    {
        echo $this->_header($key, $value) . "\n";
    }
}
_Request::$_headers = _Response::$_headers = new HeadersEcho();