protected static function overrideEnvironment(&$env) {
        $get =& $env['QUERY'];

        // Check to override the method.
        if (isset($get['x-method'])) {
            $method = strtoupper($get['x-method']);

            $getMethods = array(self::METHOD_GET, self::METHOD_HEAD, self::METHOD_OPTIONS);

            // Don't allow get style methods to be overridden to post style methods.
            if (!in_array($env['REQUEST_METHOD'], $getMethods) || in_array($method, $getMethods)) {
                static::replaceEnv($env, 'REQUEST_METHOD', $method);
            } else {
                $env['X_METHOD_BLOCKED'] = true;
            }
            unset($get['x-method']);
        }

        // Force the path and extension to lowercase.
        $path = strtolower($env['PATH_INFO']);
        if ($path !== $env['PATH_INFO']) {
            static::replaceEnv($env, 'PATH_INFO', $path);
        }

        $ext = strtolower($env['EXT']);
        if ($ext !== $env['EXT']) {
            static::replaceEnv($env, 'EXT', $ext);
        }

        // Check to override the accepts header.
        if (isset(self::$knownExtensions[$ext]) && $env['HTTP_ACCEPT'] !== 'application/internal') {
            static::replaceEnv($env, 'HTTP_ACCEPT', self::$knownExtensions[$ext]);
        }
    }