public void Null_strings_are_sanitized() { var builder = HttpQueryStringBuilder.ParseQuery(null); var query = builder.BuildQuery(); Assert.That(query.HasItems, Is.False); }
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); }
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); }
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)); }