/// <summary> /// Called when the <see cref="Uri"/> needs to be parsed. /// </summary> protected virtual void OnParseUri() { RequiresParsePath = true; _directPath = null; if (_uri == null) { _port = UnspecifiedPort; _scheme = Http; _host = string.Empty; _pathPrefix = string.Empty; _server = string.Empty; _fragment = string.Empty; PathInternal = string.Empty; _queryArgs = null; } else { _scheme = _uri.Scheme; _port = _uri.Port; _host = _uri.Host; var path = Uri.UnescapeDataString(_uri.AbsolutePath); if (path.StartsWith(PathSegmentPrefix)) { path = path.Substring(PathSegmentPrefix.Length); } var endServer = path.IndexOf(PathSegmentPrefix[0]); if (endServer < 0) { _server = path; PathInternal = string.Empty; } else { _server = path.Substring(0, endServer); PathInternal = path.Substring(endServer + 1); } _fragment = _uri.Fragment; if (_fragment.StartsWith(FragmentPrefix)) { _fragment = _fragment.Substring(FragmentPrefix.Length); } if (PathInternal.StartsWith(PathSegmentPrefix)) { PathInternal = PathInternal.Substring(PathSegmentPrefix.Length); } _queryArgs = new QueryArgsDictionary(this, _uri.Query); } }