Esempio n. 1
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder($"{UriScheme}:{Host}");

            if (QueryParams.Count != 0)
            {
                var parts = QueryParams.Select(q => Uri.EscapeDataString(q.Key) + "=" + System.Web.NBitcoin.HttpUtility.UrlEncode(q.Value))
                            .ToArray();
                builder.Append($"?{string.Join('&', parts)}");
            }
            return(builder.ToString());
        }
Esempio n. 2
0
        public string BuildUrl()
        {
            EnsureDatabaseParameterIncluded();

            var uri = Path;

            if (string.IsNullOrWhiteSpace(uri))
            {
                uri = "/databases";
            }
            var query = string.Join("&", QueryParams.Select(x => string.Format("{0}={1}", x.Key, x.Value)));

            if (string.IsNullOrEmpty(query) == false)
            {
                uri += "?" + query;
            }
            return(uri);
        }
        public override string ToString()
        {
            string result;

            if (QueryParams != null && QueryParams.Any())
            {
                var query = string.Join("&", QueryParams.Select(x => $"{x.Key}={UrlEncoder.Default.Encode(x.Value)}"));
                result = $"{Method} {Url}?{query} {Protocol}\r\n";
            }
            else
            {
                result = $"{Method} {Url} {Protocol}\r\n";
            }


            if (Headers.Count > 0)
            {
                result += string.Join("\r\n", Headers.Select(h => $"{h.Key}: {h.Value}")) + "\r\n";
            }
            else
            {
                result += "User-Agent: xxx (shell 1)\r\n";
            }

            if (!string.IsNullOrEmpty(Body))
            {
                if (!Headers.ContainsKey("Content-Length"))
                {
                    result += $"Content-Length: {Body.Length}\r\n";
                }

                result += $"\r\n{Body}";
            }

            result += "\r\n";

            var len = result.Length;

            return($"{len} {Status}\n{result}");
        }