wasSharp
/Web/wasHTTPClient.cs |
@@ -18,7 +18,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
// <summary>A portable HTTP client.</summar> |
public class wasHTTPClient |
public class wasHTTPClient : IDisposable |
{ |
private readonly HttpClient HTTPClient; |
private readonly string MediaType; |
@@ -267,5 +267,33 @@ |
return null; |
} |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a GET request to an URL with set key-value pairs. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
public async Task<byte[]> GET(string URL) |
{ |
try |
{ |
using (var response = await HTTPClient.GetAsync(URL)) |
{ |
return response.IsSuccessStatusCode ? await response.Content.ReadAsByteArrayAsync() : null; |
} |
} |
catch (Exception) |
{ |
return null; |
} |
} |
|
public void Dispose() |
{ |
if (HTTPClient != null) |
HTTPClient.Dispose(); |
} |
} |
} |