UrlDecode() public static method

public static UrlDecode ( string content ) : string>.Dictionary
content string
return string>.Dictionary
示例#1
0
        private void ParseContent()
        {
            _stream.Position = 0;

            string content;

            using (var reader = new StreamReader(_stream, Encoding.ASCII))
            {
                content = reader.ReadToEnd();
            }

            Client.PostParameters = HttpUtil.UrlDecode(content);
        }
示例#2
0
        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());
        }