private string buildGetUrl()
        {
            if (request.Parameters == null || request.Parameters.IsEmpty)
            {
                return(request.Url);
            }
            UriBuilder b = new UriBuilder(request.Url);

            b.AddParams(request.Parameters);
            return(b.ToString());
        }
Пример #2
0
        public void SimplyAddsParamToQuery()
        {
            UriBuilder b = new UriBuilder("http://test.host");

            b.AddParam("p1", "1");
            b.AddParam("p2", "2");
            Assert.AreEqual("http://test.host/?p1=1&p2=2", b.ToString());

            b.AddParams(new NameValueCollection {
                { "p3", "3" },
                { "p3", string.Empty },
                { "p4", null },
            });
            Assert.AreEqual("http://test.host/?p1=1&p2=2&p3=3&p3=&p4=", b.ToString());
        }
Пример #3
0
        /// <summary>
        /// Performs a HTTP GET request allowing parameters to be added to the URL
        /// </summary>
        /// <param name="url">to use</param>
        /// <param name="parameters">to encode to the URL</param>
        /// <param name="headers">to be used for the request</param>
        /// <param name="callback">when finished</param>
        public void Get(string url, Dictionary <string, string> parameters, Dictionary <string, string> headers, FinishCallback callback)
        {
            if (parameters != null && !parameters.IsEmpty)
            {
                UriBuilder builder = new UriBuilder(url);
                builder.AddParams(parameters);
                url = builder.ToString();
            }
            Request request = new Request {
                Url     = url,
                Method  = HttpMethod.GET,
                Cookies = Cookies,
                Headers = headers
            };

            doPerform(request, callback);
        }
Пример #4
0
        public void BatchManipulateParametersFromDict()
        {
            UriBuilder b = new UriBuilder("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=b#v");

            b.SetParams(new Dictionary <string, string>()
            {
                { "a", "c" },
                { "b", "x" }
            });
            Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=c&b=x#v", b.ToString());

            b.AddParams(new Dictionary <string, string>()
            {
                { "b", "y" },
                { "c", "z" }
            });
            Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=c&b=x&b=y&c=z#v", b.ToString());
        }