public static function getHeaders()
    {
        if (self::$headers === null) {
            if (function_exists('apache_request_headers')) {
                $headers = apache_request_headers();
            } else {
                $headers = array();
                if (isset($_SERVER['CONTENT_TYPE'])) {
                    $headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
                }
                if (isset($_ENV['CONTENT_TYPE'])) {
                    $headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
                }
                foreach ($_SERVER as $key => $value) {
                    if (substr($key, 0, 5) == "HTTP_") {
                        // this is chaos, basically it is just there to capitalize the first
                        // letter of every word that is not an initial HTTP and strip HTTP
                        // code from przemek
                        $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
                        $headers[$key] = $value;
                    }
                }
            }
            self::$headers = $headers;
        }

        return self::$headers;
    }