Skip to content

Commit f320dae

Browse files
committed
Implemented own client for async-requests (Should close #55)
1 parent 3235619 commit f320dae

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

SpotifyAPI/Web/SpotifyWebClient.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ public byte[] DownloadRaw(string url)
7171

7272
public async Task<byte[]> DownloadRawAsync(string url)
7373
{
74-
return await _webClient.DownloadDataTaskAsync(url);
74+
using (WebClient webClient = new WebClient())
75+
{
76+
webClient.Proxy = null;
77+
webClient.Encoding = _encoding;
78+
webClient.Headers = _webClient.Headers;
79+
return await _webClient.DownloadDataTaskAsync(url);
80+
}
7581
}
7682

7783
public T DownloadJson<T>(string url)
@@ -129,7 +135,13 @@ public byte[] UploadRaw(string url, string body, string method)
129135

130136
public async Task<byte[]> UploadRawAsync(string url, string body, string method)
131137
{
132-
return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body));
138+
using (WebClient webClient = new WebClient())
139+
{
140+
webClient.Proxy = null;
141+
webClient.Encoding = _encoding;
142+
webClient.Headers = _webClient.Headers;
143+
return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body));
144+
}
133145
}
134146

135147
public T UploadJson<T>(string url, string body, string method)

0 commit comments

Comments
 (0)