src/Controller/Base.php
protected function serveNotModified($file)
    {
        $oInput = Factory::service('Input');
        if (function_exists('apache_request_headers')) {

            $headers = apache_request_headers();

        } elseif ($oInput->server('HTTP_IF_NONE_MATCH')) {

            $headers                  = [];
            $headers['If-None-Match'] = $oInput->server('HTTP_IF_NONE_MATCH');

        } elseif (isset($_SERVER)) {

            /**
             * Can we work the headers out for ourself?
             * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810
             **/

            $headers = [];
            $rxHttp  = '/\AHTTP_/';
            foreach ($_SERVER as $key => $val) {

                if (preg_match($rxHttp, $key)) {

                    $arhKey    = preg_replace($rxHttp, '', $key);
                    $rxMatches = explode('_', $arhKey);

                    /**
                     * Do some nasty string manipulations to restore the original letter case
                     * this should work in most cases
                     **/

                    if (count($rxMatches) > 0 && strlen($arhKey) > 2) {
                        foreach ($rxMatches as $ak_key => $akVal) {
                            $rxMatches[$ak_key] = ucfirst($akVal);
                        }
                        $arhKey = implode('-', $rxMatches);
                    }

                    $headers[$arhKey] = $val;
                }
            }

        } else {

            //  Give up.
            return false;
        }

        if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"' . md5($file) . '"') {
            header($oInput->server('SERVER_PROTOCOL') . ' 304 Not Modified', true, 304);
            return true;
        }

        // --------------------------------------------------------------------------

        return false;
    }
protected function serveNotModified($file)
    {
        $oInput = Factory::service('Input');
        if (function_exists('apache_request_headers')) {

            $headers = apache_request_headers();

        } elseif ($oInput->server('HTTP_IF_NONE_MATCH')) {

            $headers                  = [];
            $headers['If-None-Match'] = $oInput->server('HTTP_IF_NONE_MATCH');

        } elseif (isset($_SERVER)) {

            /**
             * Can we work the headers out for ourself?
             * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810
             **/

            $headers = [];
            $rxHttp  = '/\AHTTP_/';
            foreach ($_SERVER as $key => $val) {

                if (preg_match($rxHttp, $key)) {

                    $arhKey    = preg_replace($rxHttp, '', $key);
                    $rxMatches = explode('_', $arhKey);

                    /**
                     * Do some nasty string manipulations to restore the original letter case
                     * this should work in most cases
                     **/

                    if (count($rxMatches) > 0 && strlen($arhKey) > 2) {
                        foreach ($rxMatches as $ak_key => $akVal) {
                            $rxMatches[$ak_key] = ucfirst($akVal);
                        }
                        $arhKey = implode('-', $rxMatches);
                    }

                    $headers[$arhKey] = $val;
                }
            }

        } else {

            //  Give up.
            return false;
        }

        if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"' . md5($file) . '"') {
            header($oInput->server('SERVER_PROTOCOL') . ' 304 Not Modified', true, 304);
            return true;
        }

        // --------------------------------------------------------------------------

        return false;
    }
protected function serveNotModified ( $ file ) { $ oInput = Factory :: service ( 'Input' ) ; if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } elseif ( $ oInput -> server ( 'HTTP_IF_NONE_MATCH' ) ) { $ headers = [ ] ; $ headers [ 'If-None-Match' ] = $ oInput -> server ( 'HTTP_IF_NONE_MATCH' ) ; } elseif ( isset ( $ _SERVER ) ) { /**
             * Can we work the headers out for ourself?
             * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810
             **/ $ headers = [ ] ; $ rxHttp = '/\AHTTP_/' ; foreach ( $ _SERVER as $ key => $ val ) { if ( preg_match ( $ rxHttp , $ key ) ) { $ arhKey = preg_replace ( $ rxHttp , '' , $ key ) ; $ rxMatches = explode ( '_' , $ arhKey ) ; /**
                     * Do some nasty string manipulations to restore the original letter case
                     * this should work in most cases
                     **/ if ( count ( $ rxMatches ) > 0 && strlen ( $ arhKey ) > 2 ) { foreach ( $ rxMatches as $ ak_key => $ akVal ) { $ rxMatches [ $ ak_key ] = ucfirst ( $ akVal ) ; } $ arhKey = implode ( '-' , $ rxMatches ) ; } $ headers [ $ arhKey ] = $ val ; } } } else { //  Give up. return false ; } if ( isset ( $ headers [ 'If-None-Match' ] ) && $ headers [ 'If-None-Match' ] == '"' . md5 ( $ file ) . '"' ) { header ( $ oInput -> server ( 'SERVER_PROTOCOL' ) . ' 304 Not Modified' , true , 304 ) ; return true ; } // -------------------------------------------------------------------------- return false ; }
Serve the "304 Not Modified" headers for an object

@param  string $file The file we're sending the headers for

@return boolean
Serve the 304 Not Modified headers for an object