Ejemplo n.º 1
0
        void ParseRequestLine()
        {
            var mongrelHeaders = _connection.GetHeaders();

            _verb = mongrelHeaders["METHOD"];

            _url = mongrelHeaders["URI"];

            _prot = mongrelHeaders["VERSION"];

            // query string
            int iqs = _url.IndexOf('?');

            if (iqs > 0)
            {
                _path             = _url.Substring(0, iqs);
                _queryString      = _url.Substring(iqs + 1);
                _queryStringBytes = Encoding.ASCII.GetBytes(_queryString);
            }
            else
            {
                _path             = _url;
                _queryStringBytes = new byte[0];
            }

            // url-decode path

            if (_path.IndexOf('%') >= 0)
            {
                _path = HttpUtility.UrlDecode(_path, Encoding.UTF8);

                iqs = _url.IndexOf('?');
                if (iqs >= 0)
                {
                    _url = _path + _url.Substring(iqs);
                }
                else
                {
                    _url = _path;
                }
            }

            // path info

            int lastDot = _path.LastIndexOf('.');
            int lastSlh = _path.LastIndexOf('/');

            if (lastDot >= 0 && lastSlh >= 0 && lastDot < lastSlh)
            {
                int ipi = _path.IndexOf('/', lastDot);
                _filePath = _path.Substring(0, ipi);
                _pathInfo = _path.Substring(ipi);
            }
            else
            {
                _filePath = _path;
                _pathInfo = String.Empty;
            }

            _pathTranslated = MapPath(_filePath);
        }