protected function buildWebRequest()
    {
        $args = $_REQUEST;
        $params = array();

        $route = $_SERVER['REQUEST_URI'];
        $posQuestionMark = strpos($route, '?');
        if ($posQuestionMark !== false) {
            $route = substr($route, 0, $posQuestionMark);
        }
        
        $posIndex = strpos($route, 'index.php');
        if ($posIndex !== false) {
            $route = substr($route, $posIndex + strlen('index.php'));
        }
        
        // Transform the arguments
        foreach ($args as $key => $value) {
            if (is_numeric($value)) {
                // Transform the value into the correct data type
                $value = $value * 1;
            }
            
            $params[$key] = $value;
        }

        // Generate the full url and extract the base
        $scheme = $this->getScheme();
        $fullUrl = $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

        $isSsl = false;
        if ($scheme == 'https') {
            $isSsl = true;
        }
        
        $routePosition = strlen($fullUrl);
        if ($route !== '' && $route !== '/') {
            $routePosition = strpos($fullUrl, $route);
        }
        
        $method = $_SERVER['REQUEST_METHOD'];
        $requestedUrl = $this->getRequestedUrl();
        $base = substr($fullUrl, 0, $routePosition);
        $headers = $this->getHeaders($_SERVER);
        $protocol = $_SERVER['SERVER_PROTOCOL'];
        
        $locale = 'en_US';
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $locale = $this->getLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']);
        }
        
        $operatingSystem = $this->getOperatingSystem();

        return new WebRequest($method, $requestedUrl, $route, $params, $base, $locale, $operatingSystem, $isSsl, $headers, $protocol);
    }