wasSharp – Diff between revs 55 and 56
?pathlinks?
Rev 55 | Rev 56 | |||
---|---|---|---|---|
Line 437... | Line 437... | |||
437 | |
437 | |
|
438 | /////////////////////////////////////////////////////////////////////////// |
438 | /////////////////////////////////////////////////////////////////////////// |
|
439 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
439 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
440 | /////////////////////////////////////////////////////////////////////////// |
440 | /////////////////////////////////////////////////////////////////////////// |
|
- | 441 | /// <summary> |
||
- | 442 | /// Asynchronously sends a POST request to an URL with set key-value pairs. |
||
- | 443 | /// </summary> |
||
- | 444 | /// <param name="URL">the url to send the message to</param> |
||
- | 445 | /// <param name="message">key-value pairs to send</param> |
||
- | 446 | public async Task<byte[]> POST(string URL, IEnumerable<KeyValuePair<Task<string>, Task<string>>> message) |
||
- | 447 | { |
||
- | 448 | try |
||
- | 449 | { |
||
- | 450 | using (var content = |
||
- | 451 | new StringContent(KeyValue.Encode(message), Encoding.UTF8, MediaType)) |
||
- | 452 | { |
||
- | 453 | using (var response = await HTTPClient.PostAsync(URL, content)) |
||
- | 454 | { |
||
- | 455 | return response.IsSuccessStatusCode |
||
- | 456 | ? await response.Content.ReadAsByteArrayAsync() |
||
- | 457 | : null; |
||
- | 458 | } |
||
- | 459 | } |
||
- | 460 | } |
||
- | 461 | catch (Exception) |
||
- | 462 | { |
||
- | 463 | return null; |
||
- | 464 | } |
||
- | 465 | } |
||
- | 466 | |
||
- | 467 | /////////////////////////////////////////////////////////////////////////// |
||
- | 468 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
||
- | 469 | /////////////////////////////////////////////////////////////////////////// |
||
441 | /// <summary> |
470 | /// <summary> |
|
442 | /// Sends a GET request to an URL with set key-value pairs. |
471 | /// Sends a GET request to an URL with set key-value pairs. |
|
443 | /// </summary> |
472 | /// </summary> |
|
444 | /// <param name="URL">the url to send the message to</param> |
473 | /// <param name="URL">the url to send the message to</param> |
|
445 | /// <param name="message">key-value pairs to send</param> |
474 | /// <param name="message">key-value pairs to send</param> |