/Web/wasHTTPClient.cs |
@@ -101,7 +101,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with binary data. |
/// Sends a PUT request to an URL with binary data. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -149,7 +149,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with text. |
/// Sends a PUT request to an URL with text. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -198,7 +198,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with binary data. |
/// Sends a PUT request to an URL with binary data. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -226,7 +226,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with stream content data. |
/// Sends a PUT request to an URL with stream content data. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -254,7 +254,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a DELETE request to an URL with stream content data. |
/// Sends a DELETE request to an URL with stream content data. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -288,7 +288,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with text. |
/// Sends a PUT request to an URL with text. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -317,7 +317,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a PUT request to an URL with text. |
/// Sends a PUT request to an URL with text. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="data">key-value pairs to send</param> |
@@ -352,7 +352,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a POST request to an URL with set key-value pairs. |
/// Sends a POST request to an URL with set key-value pairs. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="message">key-value pairs to send</param> |
@@ -381,7 +381,7 @@ |
// Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a POST request to an URL with set message. |
/// Sends a POST request to an URL with set message. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="message">the message to send</param> |
@@ -410,7 +410,7 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a POST request to an URL with set key-value pairs. |
/// Sends a POST request to an URL with set key-value pairs. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="message">key-value pairs to send</param> |
@@ -439,10 +439,39 @@ |
// Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a GET request to an URL with set key-value pairs. |
/// Asynchronously sends a POST request to an URL with set key-value pairs. |
/// </summary> |
/// <param name="URL">the url to send the message to</param> |
/// <param name="message">key-value pairs to send</param> |
public async Task<byte[]> POST(string URL, IEnumerable<KeyValuePair<Task<string>, Task<string>>> message) |
{ |
try |
{ |
using (var content = |
new StringContent(KeyValue.Encode(message), Encoding.UTF8, MediaType)) |
{ |
using (var response = await HTTPClient.PostAsync(URL, content)) |
{ |
return response.IsSuccessStatusCode |
? await response.Content.ReadAsByteArrayAsync() |
: null; |
} |
} |
} |
catch (Exception) |
{ |
return null; |
} |
} |
|
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) 2014 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> |
/// <param name="message">key-value pairs to send</param> |
public async Task<byte[]> GET(string URL, Dictionary<string, string> message) |
{ |
try |
@@ -464,7 +493,7 @@ |
// Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // |
/////////////////////////////////////////////////////////////////////////// |
/// <summary> |
/// Sends a GET request to an URL with set key-value pairs. |
/// 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) |
@@ -483,9 +512,9 @@ |
} |
} |
|
public void Dispose() |
{ |
((IDisposable)HTTPClient).Dispose(); |
} |
public void Dispose() |
{ |
((IDisposable)HTTPClient).Dispose(); |
} |
} |
} |