wasSharp – Diff between revs 34 and 39
?pathlinks?
Rev 34 | Rev 39 | |||
---|---|---|---|---|
Line 371... | Line 371... | |||
371 | return null; |
371 | return null; |
|
372 | } |
372 | } |
|
373 | } |
373 | } |
|
Line 374... | Line 374... | |||
374 | |
374 | |
|
- | 375 | /////////////////////////////////////////////////////////////////////////// |
||
- | 376 | // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 // |
||
- | 377 | /////////////////////////////////////////////////////////////////////////// |
||
- | 378 | /// <summary> |
||
- | 379 | /// Sends a POST request to an URL with set message. |
||
- | 380 | /// </summary> |
||
- | 381 | /// <param name="URL">the url to send the message to</param> |
||
- | 382 | /// <param name="message">the message to send</param> |
||
- | 383 | public async Task<byte[]> POST(string URL, string message) |
||
- | 384 | { |
||
- | 385 | try |
||
- | 386 | { |
||
- | 387 | using (var content = |
||
- | 388 | new StringContent(message, Encoding.UTF8, MediaType)) |
||
- | 389 | { |
||
- | 390 | using (var response = await HTTPClient.PostAsync(URL, content)) |
||
- | 391 | { |
||
- | 392 | return response.IsSuccessStatusCode |
||
- | 393 | ? await response.Content.ReadAsByteArrayAsync() |
||
- | 394 | : null; |
||
- | 395 | } |
||
- | 396 | } |
||
- | 397 | } |
||
- | 398 | catch (Exception) |
||
- | 399 | { |
||
- | 400 | return null; |
||
- | 401 | } |
||
- | 402 | } |
||
- | 403 | |
||
375 | /////////////////////////////////////////////////////////////////////////// |
404 | /////////////////////////////////////////////////////////////////////////// |
|
376 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
405 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
377 | /////////////////////////////////////////////////////////////////////////// |
406 | /////////////////////////////////////////////////////////////////////////// |
|
378 | /// <summary> |
407 | /// <summary> |
|
379 | /// Sends a POST request to an URL with set key-value pairs. |
408 | /// Sends a POST request to an URL with set key-value pairs. |