Esempio n. 1
0
        public void Null_strings_are_sanitized()
        {
            var builder = HttpQueryStringBuilder.ParseQuery(null);

            var query = builder.BuildQuery();

            Assert.That(query.HasItems, Is.False);
        }
Esempio n. 2
0
        public void Question_mark_is_removed(string key, string value)
        {
            var querystring = $"?{key}={value}";

            var builder = HttpQueryStringBuilder.ParseQuery(querystring);

            Assert.That(builder.HasKey(key), Is.True);
        }
Esempio n. 3
0
        public void Simple_query_can_be_parsed(string key, string value)
        {
            var querystring = $"{key}={value}";

            var builder = HttpQueryStringBuilder.ParseQuery(querystring);

            Assert.That(builder.HasKey(key), Is.True);
        }
Esempio n. 4
0
        public void Query_with_forged_key_can_be_parsed(string keyFirst, string keySecond, string value)
        {
            var key = $"{keyFirst}&{keySecond}";

            var querystring = $"{WebUtility.UrlEncode(key)}={value}";

            var builder = HttpQueryStringBuilder.ParseQuery(querystring);

            Assert.That(builder.HasKey(key), Is.True);
        }
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var uri        = request.RequestUri;
            var uriBuilder = new UriBuilder(uri);

            var queryStringBuilder = HttpQueryStringBuilder.ParseQuery(uriBuilder.Query);

            queryStringBuilder.Add("hapikey", _options.ApiKey);

            uriBuilder.Query   = queryStringBuilder.BuildQuery();
            request.RequestUri = uriBuilder.Uri;

            return(base.SendAsync(request, cancellationToken));
        }