Example #1
0
        public void AppendingPathAfterQueryAndSettingTheUriWorks()
        {
            var uriBuilder = new HttpPipelineUriBuilder();

            uriBuilder.Uri = new Uri("http://localhost/");
            uriBuilder.AppendQuery("query", "value");
            uriBuilder.AppendPath("a");
            uriBuilder.AppendPath("b");
            uriBuilder.AppendQuery("c", "d");

            Assert.AreEqual("http://localhost/ab?query=value&c=d", uriBuilder.Uri.ToString());
        }
Example #2
0
        public void AppendQueryWorks(string initialQuery, string expectedResult)
        {
            var uriBuilder = new HttpPipelineUriBuilder();

            uriBuilder.Scheme = "http";
            uriBuilder.Host   = "localhost";
            uriBuilder.Port   = 80;
            uriBuilder.Query  = initialQuery;
            uriBuilder.AppendQuery("a", "b");
            uriBuilder.AppendQuery("c", "d");

            Assert.AreEqual(expectedResult, uriBuilder.Uri.ToString());
        }
Example #3
0
        internal void BuildBatchQuery(HttpPipelineUriBuilder builder, SettingSelector selector)
        {
            if (selector.Keys.Count > 0)
            {
                var keysCopy = new List <string>();
                foreach (var key in selector.Keys)
                {
                    if (key.IndexOfAny(ReservedCharacters) != -1)
                    {
                        keysCopy.Add(EscapeReservedCharacters(key));
                    }
                    else
                    {
                        keysCopy.Add(key);
                    }
                }
                var keys = string.Join(",", keysCopy).ToLower();
                builder.AppendQuery(KeyQueryFilter, keys);
            }

            if (selector.Labels.Count > 0)
            {
                var labelsCopy = new List <string>();
                foreach (var label in selector.Labels)
                {
                    if (label == string.Empty)
                    {
                        labelsCopy.Add("\0");
                    }
                    else
                    {
                        labelsCopy.Add(EscapeReservedCharacters(label));
                    }
                }
                var labels = string.Join(",", labelsCopy).ToLower();
                builder.AppendQuery(LabelQueryFilter, labels);
            }

            if (selector.Fields != SettingFields.All)
            {
                var filter = (selector.Fields).ToString().ToLower();
                builder.AppendQuery(FieldsQueryFilter, filter);
            }

            if (!string.IsNullOrEmpty(selector.BatchLink))
            {
                builder.AppendQuery("after", selector.BatchLink);
            }
        }
Example #4
0
        public void AppendingQueryResetsUri()
        {
            var uriBuilder = new HttpPipelineUriBuilder();

            uriBuilder.Uri = new Uri("http://localhost/");
            uriBuilder.AppendQuery("a", "b");

            Assert.AreEqual("http://localhost/?a=b", uriBuilder.Uri.ToString());
        }
Example #5
0
        private Uri CreateFirstPageUri(string path)
        {
            var firstPage = new HttpPipelineUriBuilder();

            firstPage.Uri = _vaultUri;
            firstPage.AppendPath(path);
            firstPage.AppendQuery("api-version", ApiVersion);

            return(firstPage.Uri);
        }
Example #6
0
        => BuildUriForKvRoute(builder, keyValue.Key, keyValue.Label);     // TODO (pri 2) : does this need to filter ETag?

        void BuildUriForKvRoute(HttpPipelineUriBuilder builder, string key, string label)
        {
            builder.Uri = _baseUri;
            builder.AppendPath(KvRoute);
            builder.AppendPath(key);

            if (label != null)
            {
                builder.AppendQuery(LabelQueryFilter, label);
            }
        }
Example #7
0
        public void AppendQueryWithEmptyValueWorks()
        {
            var uriBuilder = new HttpPipelineUriBuilder();

            uriBuilder.Scheme = "http";
            uriBuilder.Host   = "localhost";
            uriBuilder.Port   = 80;
            uriBuilder.AppendQuery("a", null);

            Assert.AreEqual("http://localhost/?a=", uriBuilder.Uri.ToString());
        }