/* * POST METHODS */ /// <summary>Automatically builds a POST query string from a <see cref="StringPairCollection"/> /// using <see cref="Encoding.UTF8"/> encoding and the provided Content-Type.</summary> public static async Task <HttpResponseMessage> PostAsync (this HttpClient httpClient, string url, StringPairCollection pairs, CancellationToken cancellationToken = default, string mediaType = "application/x-www-form-urlencoded") { return(await httpClient.PostAsync(url, new StringContent(pairs.ToHttpQueryString(), Encoding.UTF8, mediaType), cancellationToken).ConfigureAwait(false)); }
/* * GET METHODS */ /// <summary>Automatically builds a GET query string from a <see cref="StringPairCollection"/> /// and appends it to the provided URL.</summary> public async static Task <HttpResponseMessage> GetAsync (this HttpClient httpClient, string url, StringPairCollection pairs, CancellationToken cancellationToken = default) { return(await httpClient.GetAsync($"{url}?{pairs.ToHttpQueryString()}", cancellationToken)); }