NHttp.HttpRequest.ParsePath C# (CSharp) Method

ParsePath() private method

private ParsePath ( HttpClient client ) : void
client HttpClient
return void
        private void ParsePath(HttpClient client)
        {
            RawUrl = client.Request;

            string[] parts = client.Request.Split(new[] { '?' }, 2);

            Path = parts[0];

            if (parts.Length == 2)
                QueryString = CreateCollection(HttpUtil.UrlDecode(parts[1]));
            else
                QueryString = new NameValueCollection();

            string host;
            string port;
            string hostHeader;

            if (client.Headers.TryGetValue("Host", out hostHeader))
            {
                parts = hostHeader.Split(new[] { ':' }, 2);

                host = parts[0];

                if (parts.Length == 2)
                    port = parts[1];
                else
                    port = null;
            }
            else
            {
                var endPoint = client.Server.EndPoint;

                host = endPoint.Address.ToString();
                
                if (endPoint.Port == 80)
                    port = null;
                else
                    port = endPoint.Port.ToString(CultureInfo.InvariantCulture);
            }

            var sb = new StringBuilder();

            sb.Append("http://");
            sb.Append(host);

            if (port != null)
            {
                sb.Append(':');
                sb.Append(port);
            }

            sb.Append(client.Request);

            Url = new Uri(sb.ToString());
        }