From 3eefa5a2dcd4850a784e43b0eae36fc74fec21e3 Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Wed, 31 May 2017 19:54:13 +0200 Subject: [PATCH] Fixed Header add --- SpotifyAPI/Web/IClient.cs | 12 ++++++++++++ SpotifyAPI/Web/SpotifyWebClient.cs | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/SpotifyAPI/Web/IClient.cs b/SpotifyAPI/Web/IClient.cs index 86e4ed2e..1fcef62e 100644 --- a/SpotifyAPI/Web/IClient.cs +++ b/SpotifyAPI/Web/IClient.cs @@ -15,6 +15,7 @@ namespace SpotifyAPI.Web /// Downloads data from an URL and returns it /// /// An URL + /// /// Tuple Download(string url, Dictionary headers = null); @@ -22,6 +23,7 @@ namespace SpotifyAPI.Web /// Downloads data async from an URL and returns it /// /// + /// /// Task> DownloadAsync(string url, Dictionary headers = null); @@ -29,6 +31,7 @@ namespace SpotifyAPI.Web /// Downloads data from an URL and returns it /// /// An URL + /// /// Tuple DownloadRaw(string url, Dictionary headers = null); @@ -36,6 +39,7 @@ namespace SpotifyAPI.Web /// Downloads data async from an URL and returns it /// /// + /// /// Task> DownloadRawAsync(string url, Dictionary headers = null); @@ -44,6 +48,7 @@ namespace SpotifyAPI.Web /// /// The Type which the object gets converted to /// An URL + /// /// Tuple DownloadJson(string url, Dictionary headers = null); @@ -52,6 +57,7 @@ namespace SpotifyAPI.Web /// /// The Type which the object gets converted to /// An URL + /// /// Task> DownloadJsonAsync(string url, Dictionary headers = null); @@ -61,6 +67,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Tuple Upload(string url, string body, string method, Dictionary headers = null); @@ -70,6 +77,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Task> UploadAsync(string url, string body, string method, Dictionary headers = null); @@ -79,6 +87,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Tuple UploadRaw(string url, string body, string method, Dictionary headers = null); @@ -88,6 +97,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Task> UploadRawAsync(string url, string body, string method, Dictionary headers = null); @@ -98,6 +108,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Tuple UploadJson(string url, string body, string method, Dictionary headers = null); @@ -108,6 +119,7 @@ namespace SpotifyAPI.Web /// An URL /// The Body-Data (most likely a JSON String) /// The Upload-method (POST,DELETE,PUT) + /// /// Task> UploadJsonAsync(string url, string body, string method, Dictionary headers = null); } diff --git a/SpotifyAPI/Web/SpotifyWebClient.cs b/SpotifyAPI/Web/SpotifyWebClient.cs index c0b418f8..4205e381 100644 --- a/SpotifyAPI/Web/SpotifyWebClient.cs +++ b/SpotifyAPI/Web/SpotifyWebClient.cs @@ -38,7 +38,7 @@ namespace SpotifyAPI.Web { foreach (KeyValuePair headerPair in headers) { - client.DefaultRequestHeaders.Add(headerPair.Key, headerPair.Value); + client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value); } } using (HttpResponseMessage response = Task.Run(() => client.GetAsync(url)).Result) @@ -60,7 +60,7 @@ namespace SpotifyAPI.Web { foreach (KeyValuePair headerPair in headers) { - client.DefaultRequestHeaders.Add(headerPair.Key, headerPair.Value); + client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value); } } using (HttpResponseMessage response = await client.GetAsync(url).ConfigureAwait(false)) @@ -106,7 +106,7 @@ namespace SpotifyAPI.Web { foreach (KeyValuePair headerPair in headers) { - client.DefaultRequestHeaders.Add(headerPair.Key, headerPair.Value); + client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value); } } @@ -133,7 +133,7 @@ namespace SpotifyAPI.Web { foreach (KeyValuePair headerPair in headers) { - client.DefaultRequestHeaders.Add(headerPair.Key, headerPair.Value); + client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value); } }