src/Mvc/Util/RequestParser.php
private static function parseParameters(Request &$req, $serverVars)
    {
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT', 'Accept');
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT_LANGUAGE', 'Accept-Language');
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT_ENCODING', 'Accept-Encoding');
        self::parseElement($req, $serverVars, 'HTTP_UA_CPU', 'User-Agent-CPU');
        self::parseElement($req, $serverVars, 'HTTP_USER_AGENT', 'User-Agent');
        self::parseElement($req, $serverVars, 'HTTP_HOST', 'Host');
        self::parseElement($req, $serverVars, 'HTTP_CACHE_COTROL', 'Cache-Control');
        self::parseElement($req, $serverVars, 'HTTP_CONNECTION', 'Connection');
        self::parseElement($req, $serverVars, 'HTTP_X_FORWARDED_FOR', 'X-Forwarded-For');
        
        if (isset($req->params['Accept-Language'])) {
            $accepted = explode(',', $req->params['Accept-Language']);
            $req->params['Accept-Language-Best'] = $accepted[0];
            foreach ($accepted as $acceptedLang) {
                $matches = array();
                // TODO: Respect the quality field from rfc2616
                if (preg_match("/^((?i)[a-z]{2}[-_](?:[a-z]{2}){1,2}(?:_[a-z]{2})?).*/", $acceptedLang, $matches)) {
                    $req->params['Accept-Language-Best'] = $matches[1];
                    break;
                }
            }
        }
    }
private static function parseParameters(Request &$req, $serverVars)
    {
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT', 'Accept');
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT_LANGUAGE', 'Accept-Language');
        self::parseElement($req, $serverVars, 'HTTP_ACCEPT_ENCODING', 'Accept-Encoding');
        self::parseElement($req, $serverVars, 'HTTP_UA_CPU', 'User-Agent-CPU');
        self::parseElement($req, $serverVars, 'HTTP_USER_AGENT', 'User-Agent');
        self::parseElement($req, $serverVars, 'HTTP_HOST', 'Host');
        self::parseElement($req, $serverVars, 'HTTP_CACHE_COTROL', 'Cache-Control');
        self::parseElement($req, $serverVars, 'HTTP_CONNECTION', 'Connection');
        self::parseElement($req, $serverVars, 'HTTP_X_FORWARDED_FOR', 'X-Forwarded-For');
        
        if (isset($req->params['Accept-Language'])) {
            $accepted = explode(',', $req->params['Accept-Language']);
            $req->params['Accept-Language-Best'] = $accepted[0];
            foreach ($accepted as $acceptedLang) {
                $matches = array();
                // TODO: Respect the quality field from rfc2616
                if (preg_match("/^((?i)[a-z]{2}[-_](?:[a-z]{2}){1,2}(?:_[a-z]{2})?).*/", $acceptedLang, $matches)) {
                    $req->params['Accept-Language-Best'] = $matches[1];
                    break;
                }
            }
        }
    }
private static function parseParameters ( Request & $ req , $ serverVars ) { self :: parseElement ( $ req , $ serverVars , 'HTTP_ACCEPT' , 'Accept' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_ACCEPT_LANGUAGE' , 'Accept-Language' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_ACCEPT_ENCODING' , 'Accept-Encoding' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_UA_CPU' , 'User-Agent-CPU' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_USER_AGENT' , 'User-Agent' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_HOST' , 'Host' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_CACHE_COTROL' , 'Cache-Control' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_CONNECTION' , 'Connection' ) ; self :: parseElement ( $ req , $ serverVars , 'HTTP_X_FORWARDED_FOR' , 'X-Forwarded-For' ) ; if ( isset ( $ req -> params [ 'Accept-Language' ] ) ) { $ accepted = explode ( ',' , $ req -> params [ 'Accept-Language' ] ) ; $ req -> params [ 'Accept-Language-Best' ] = $ accepted [ 0 ] ; foreach ( $ accepted as $ acceptedLang ) { $ matches = array ( ) ; // TODO: Respect the quality field from rfc2616 if ( preg_match ( "/^((?i)[a-z]{2}[-_](?:[a-z]{2}){1,2}(?:_[a-z]{2})?).*/" , $ acceptedLang , $ matches ) ) { $ req -> params [ 'Accept-Language-Best' ] = $ matches [ 1 ] ; break ; } } } }
Parse the server variables which represents HTTP headers into parameter values for the request object

@param Request $req
The request object
@param array $serverVars
The server variables provided by sapi
Parse the server variables which represents HTTP headers into parameter values for the request object