From f320dae4ceebd88beb42d653fed5638171d5cd59 Mon Sep 17 00:00:00 2001 From: "Johnny @PC" Date: Sun, 15 Nov 2015 20:54:30 +0100 Subject: [PATCH] Implemented own client for async-requests (Should close #55) --- SpotifyAPI/Web/SpotifyWebClient.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/SpotifyAPI/Web/SpotifyWebClient.cs b/SpotifyAPI/Web/SpotifyWebClient.cs index 40533088..8ad55203 100644 --- a/SpotifyAPI/Web/SpotifyWebClient.cs +++ b/SpotifyAPI/Web/SpotifyWebClient.cs @@ -71,7 +71,13 @@ namespace SpotifyAPI.Web public async Task DownloadRawAsync(string url) { - return await _webClient.DownloadDataTaskAsync(url); + using (WebClient webClient = new WebClient()) + { + webClient.Proxy = null; + webClient.Encoding = _encoding; + webClient.Headers = _webClient.Headers; + return await _webClient.DownloadDataTaskAsync(url); + } } public T DownloadJson(string url) @@ -129,7 +135,13 @@ namespace SpotifyAPI.Web public async Task UploadRawAsync(string url, string body, string method) { - return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body)); + using (WebClient webClient = new WebClient()) + { + webClient.Proxy = null; + webClient.Encoding = _encoding; + webClient.Headers = _webClient.Headers; + return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body)); + } } public T UploadJson(string url, string body, string method)