private void ParseRequestLine() { ByteString[] strArray = ((ByteString)this._headerByteStrings[0]).Split(' '); if (((strArray != null) && (strArray.Length >= 2)) && (strArray.Length <= 3)) { this._verb = strArray[0].GetString(); ByteString str2 = strArray[1]; this._url = str2.GetString(); if (strArray.Length == 3) { this._prot = strArray[2].GetString(); } else { this._prot = "HTTP/1.0"; } int index = str2.IndexOf('?'); if (index > 0) { this._queryStringBytes = str2.Substring(index + 1).GetBytes(); } else { this._queryStringBytes = new byte[0]; } index = this._url.IndexOf('?'); if (index > 0) { this._path = this._url.Substring(0, index); this._queryString = this._url.Substring(index + 1); } else { this._path = this._url; this._queryStringBytes = new byte[0]; } if (this._path.IndexOf('%') >= 0) { this._path = HttpUtility.UrlDecode(this._path); } int startIndex = this._path.LastIndexOf('.'); int num3 = this._path.LastIndexOf('/'); if (((startIndex >= 0) && (num3 >= 0)) && (startIndex < num3)) { int length = this._path.IndexOf('/', startIndex); this._filePath = this._path.Substring(0, length); this._pathInfo = this._path.Substring(length); } else { this._filePath = this._path; this._pathInfo = string.Empty; } this._pathTranslated = this.MapPath(this._filePath); } }
void ParseRequestLine() { ByteString requestLine = _headerByteStrings[0]; ByteString[] elems = requestLine.Split(' '); if (elems == null || elems.Length < 2 || elems.Length > 3) { _connection.WriteErrorAndClose(400); return; } _verb = elems[0].GetString(); ByteString urlBytes = elems[1]; _url = urlBytes.GetString(); if (elems.Length == 3) { _prot = elems[2].GetString(); } else { _prot = "HTTP/1.0"; } // query string int iqs = urlBytes.IndexOf('?'); if (iqs > 0) { _queryStringBytes = urlBytes.Substring(iqs+1).GetBytes(); } else { _queryStringBytes = new byte[0]; } iqs = _url.IndexOf('?'); if (iqs > 0) { _path = _url.Substring(0, iqs); _queryString = _url.Substring(iqs+1); } 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); }