Implemented own client for async-requests (Should close #55)

This commit is contained in:
Johnny @PC 2015-11-15 20:54:30 +01:00
parent 323561909e
commit f320dae4ce

View File

@ -71,8 +71,14 @@ namespace SpotifyAPI.Web
public async Task<byte[]> DownloadRawAsync(string url) public async Task<byte[]> DownloadRawAsync(string url)
{ {
using (WebClient webClient = new WebClient())
{
webClient.Proxy = null;
webClient.Encoding = _encoding;
webClient.Headers = _webClient.Headers;
return await _webClient.DownloadDataTaskAsync(url); return await _webClient.DownloadDataTaskAsync(url);
} }
}
public T DownloadJson<T>(string url) public T DownloadJson<T>(string url)
{ {
@ -129,8 +135,14 @@ namespace SpotifyAPI.Web
public async Task<byte[]> UploadRawAsync(string url, string body, string method) public async Task<byte[]> UploadRawAsync(string url, string body, string method)
{ {
using (WebClient webClient = new WebClient())
{
webClient.Proxy = null;
webClient.Encoding = _encoding;
webClient.Headers = _webClient.Headers;
return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body)); return await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body));
} }
}
public T UploadJson<T>(string url, string body, string method) public T UploadJson<T>(string url, string body, string method)
{ {