wasSharp – Diff between revs 55 and 56
?pathlinks?
Rev 55 | Rev 56 | |||
---|---|---|---|---|
Line 99... | Line 99... | |||
99 | |
99 | |
|
100 | /////////////////////////////////////////////////////////////////////////// |
100 | /////////////////////////////////////////////////////////////////////////// |
|
101 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
101 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
102 | /////////////////////////////////////////////////////////////////////////// |
102 | /////////////////////////////////////////////////////////////////////////// |
|
103 | /// <summary> |
103 | /// <summary> |
|
104 | /// Sends a PUT request to an URL with binary data. |
104 | /// Sends a PUT request to an URL with binary data. |
|
105 | /// </summary> |
105 | /// </summary> |
|
106 | /// <param name="URL">the url to send the message to</param> |
106 | /// <param name="URL">the url to send the message to</param> |
|
107 | /// <param name="data">key-value pairs to send</param> |
107 | /// <param name="data">key-value pairs to send</param> |
|
108 | /// <param name="headers">headers to send with the request</param> |
108 | /// <param name="headers">headers to send with the request</param> |
|
Line 147... | Line 147... | |||
147 | |
147 | |
|
148 | /////////////////////////////////////////////////////////////////////////// |
148 | /////////////////////////////////////////////////////////////////////////// |
|
149 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
149 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
150 | /////////////////////////////////////////////////////////////////////////// |
150 | /////////////////////////////////////////////////////////////////////////// |
|
151 | /// <summary> |
151 | /// <summary> |
|
152 | /// Sends a PUT request to an URL with text. |
152 | /// Sends a PUT request to an URL with text. |
|
153 | /// </summary> |
153 | /// </summary> |
|
154 | /// <param name="URL">the url to send the message to</param> |
154 | /// <param name="URL">the url to send the message to</param> |
|
155 | /// <param name="data">key-value pairs to send</param> |
155 | /// <param name="data">key-value pairs to send</param> |
|
156 | /// <param name="headers">headers to send with the request</param> |
156 | /// <param name="headers">headers to send with the request</param> |
|
Line 196... | Line 196... | |||
196 | |
196 | |
|
197 | /////////////////////////////////////////////////////////////////////////// |
197 | /////////////////////////////////////////////////////////////////////////// |
|
198 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
198 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
199 | /////////////////////////////////////////////////////////////////////////// |
199 | /////////////////////////////////////////////////////////////////////////// |
|
200 | /// <summary> |
200 | /// <summary> |
|
201 | /// Sends a PUT request to an URL with binary data. |
201 | /// Sends a PUT request to an URL with binary data. |
|
202 | /// </summary> |
202 | /// </summary> |
|
203 | /// <param name="URL">the url to send the message to</param> |
203 | /// <param name="URL">the url to send the message to</param> |
|
204 | /// <param name="data">key-value pairs to send</param> |
204 | /// <param name="data">key-value pairs to send</param> |
|
205 | public async Task<byte[]> PUT(string URL, byte[] data) |
205 | public async Task<byte[]> PUT(string URL, byte[] data) |
|
Line 224... | Line 224... | |||
224 | |
224 | |
|
225 | /////////////////////////////////////////////////////////////////////////// |
225 | /////////////////////////////////////////////////////////////////////////// |
|
226 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
226 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
227 | /////////////////////////////////////////////////////////////////////////// |
227 | /////////////////////////////////////////////////////////////////////////// |
|
228 | /// <summary> |
228 | /// <summary> |
|
229 | /// Sends a PUT request to an URL with stream content data. |
229 | /// Sends a PUT request to an URL with stream content data. |
|
230 | /// </summary> |
230 | /// </summary> |
|
231 | /// <param name="URL">the url to send the message to</param> |
231 | /// <param name="URL">the url to send the message to</param> |
|
232 | /// <param name="data">key-value pairs to send</param> |
232 | /// <param name="data">key-value pairs to send</param> |
|
233 | public async Task<byte[]> PUT(string URL, Stream data) |
233 | public async Task<byte[]> PUT(string URL, Stream data) |
|
Line 252... | Line 252... | |||
252 | |
252 | |
|
253 | /////////////////////////////////////////////////////////////////////////// |
253 | /////////////////////////////////////////////////////////////////////////// |
|
254 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
254 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
255 | /////////////////////////////////////////////////////////////////////////// |
255 | /////////////////////////////////////////////////////////////////////////// |
|
256 | /// <summary> |
256 | /// <summary> |
|
257 | /// Sends a DELETE request to an URL with stream content data. |
257 | /// Sends a DELETE request to an URL with stream content data. |
|
258 | /// </summary> |
258 | /// </summary> |
|
259 | /// <param name="URL">the url to send the message to</param> |
259 | /// <param name="URL">the url to send the message to</param> |
|
260 | /// <param name="data">key-value pairs to send</param> |
260 | /// <param name="data">key-value pairs to send</param> |
|
261 | public async Task<byte[]> DELETE(string URL, Stream data) |
261 | public async Task<byte[]> DELETE(string URL, Stream data) |
|
Line 286... | Line 286... | |||
286 | |
286 | |
|
287 | /////////////////////////////////////////////////////////////////////////// |
287 | /////////////////////////////////////////////////////////////////////////// |
|
288 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
288 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
289 | /////////////////////////////////////////////////////////////////////////// |
289 | /////////////////////////////////////////////////////////////////////////// |
|
290 | /// <summary> |
290 | /// <summary> |
|
291 | /// Sends a PUT request to an URL with text. |
291 | /// Sends a PUT request to an URL with text. |
|
292 | /// </summary> |
292 | /// </summary> |
|
293 | /// <param name="URL">the url to send the message to</param> |
293 | /// <param name="URL">the url to send the message to</param> |
|
294 | /// <param name="data">key-value pairs to send</param> |
294 | /// <param name="data">key-value pairs to send</param> |
|
295 | public async Task<byte[]> PUT(string URL, string data) |
295 | public async Task<byte[]> PUT(string URL, string data) |
|
Line 315... | Line 315... | |||
315 | |
315 | |
|
316 | /////////////////////////////////////////////////////////////////////////// |
316 | /////////////////////////////////////////////////////////////////////////// |
|
317 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
317 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
318 | /////////////////////////////////////////////////////////////////////////// |
318 | /////////////////////////////////////////////////////////////////////////// |
|
319 | /// <summary> |
319 | /// <summary> |
|
320 | /// Sends a PUT request to an URL with text. |
320 | /// Sends a PUT request to an URL with text. |
|
321 | /// </summary> |
321 | /// </summary> |
|
322 | /// <param name="URL">the url to send the message to</param> |
322 | /// <param name="URL">the url to send the message to</param> |
|
323 | /// <param name="data">key-value pairs to send</param> |
323 | /// <param name="data">key-value pairs to send</param> |
|
324 | public async Task<byte[]> DELETE(string URL, string data) |
324 | public async Task<byte[]> DELETE(string URL, string data) |
|
Line 350... | Line 350... | |||
350 | |
350 | |
|
351 | /////////////////////////////////////////////////////////////////////////// |
351 | /////////////////////////////////////////////////////////////////////////// |
|
352 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
352 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
353 | /////////////////////////////////////////////////////////////////////////// |
353 | /////////////////////////////////////////////////////////////////////////// |
|
354 | /// <summary> |
354 | /// <summary> |
|
355 | /// Sends a POST request to an URL with set key-value pairs. |
355 | /// Sends a POST request to an URL with set key-value pairs. |
|
356 | /// </summary> |
356 | /// </summary> |
|
357 | /// <param name="URL">the url to send the message to</param> |
357 | /// <param name="URL">the url to send the message to</param> |
|
358 | /// <param name="message">key-value pairs to send</param> |
358 | /// <param name="message">key-value pairs to send</param> |
|
359 | public async Task<byte[]> POST(string URL, Dictionary<string, string> message) |
359 | public async Task<byte[]> POST(string URL, Dictionary<string, string> message) |
|
Line 379... | Line 379... | |||
379 | |
379 | |
|
380 | /////////////////////////////////////////////////////////////////////////// |
380 | /////////////////////////////////////////////////////////////////////////// |
|
381 | // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 // |
381 | // Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 // |
|
382 | /////////////////////////////////////////////////////////////////////////// |
382 | /////////////////////////////////////////////////////////////////////////// |
|
383 | /// <summary> |
383 | /// <summary> |
|
384 | /// Sends a POST request to an URL with set message. |
384 | /// Sends a POST request to an URL with set message. |
|
385 | /// </summary> |
385 | /// </summary> |
|
386 | /// <param name="URL">the url to send the message to</param> |
386 | /// <param name="URL">the url to send the message to</param> |
|
387 | /// <param name="message">the message to send</param> |
387 | /// <param name="message">the message to send</param> |
|
388 | public async Task<byte[]> POST(string URL, string message) |
388 | public async Task<byte[]> POST(string URL, string message) |
|
Line 408... | Line 408... | |||
408 | |
408 | |
|
409 | /////////////////////////////////////////////////////////////////////////// |
409 | /////////////////////////////////////////////////////////////////////////// |
|
410 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
410 | // Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3 // |
|
411 | /////////////////////////////////////////////////////////////////////////// |
411 | /////////////////////////////////////////////////////////////////////////// |
|
412 | /// <summary> |
412 | /// <summary> |
|
413 | /// Sends a POST request to an URL with set key-value pairs. |
413 | /// Sends a POST request to an URL with set key-value pairs. |
|
414 | /// </summary> |
414 | /// </summary> |
|
415 | /// <param name="URL">the url to send the message to</param> |
415 | /// <param name="URL">the url to send the message to</param> |
|
416 | /// <param name="message">key-value pairs to send</param> |
416 | /// <param name="message">key-value pairs to send</param> |
|
417 | public async Task<byte[]> POST(string URL, IEnumerable<KeyValuePair<string, string>> message) |
417 | public async Task<byte[]> POST(string URL, IEnumerable<KeyValuePair<string, string>> message) |
|
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> |
|
446 | public async Task<byte[]> GET(string URL, Dictionary<string, string> message) |
475 | public async Task<byte[]> GET(string URL, Dictionary<string, string> message) |
|
Line 462... | Line 491... | |||
462 | |
491 | |
|
463 | /////////////////////////////////////////////////////////////////////////// |
492 | /////////////////////////////////////////////////////////////////////////// |
|
464 | // Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // |
493 | // Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3 // |
|
465 | /////////////////////////////////////////////////////////////////////////// |
494 | /////////////////////////////////////////////////////////////////////////// |
|
466 | /// <summary> |
495 | /// <summary> |
|
467 | /// Sends a GET request to an URL with set key-value pairs. |
496 | /// Sends a GET request to an URL with set key-value pairs. |
|
468 | /// </summary> |
497 | /// </summary> |
|
469 | /// <param name="URL">the url to send the message to</param> |
498 | /// <param name="URL">the url to send the message to</param> |
|
470 | public async Task<byte[]> GET(string URL) |
499 | public async Task<byte[]> GET(string URL) |
|
471 | { |
500 | { |
|
Line 481... | Line 510... | |||
481 | { |
510 | { |
|
482 | return null; |
511 | return null; |
|
483 | } |
512 | } |
|
484 | } |
513 | } |
|
Line 485... | Line 514... | |||
485 | |
514 | |
|
486 | public void Dispose() |
515 | public void Dispose() |
|
487 | { |
516 | { |
|
488 | ((IDisposable)HTTPClient).Dispose(); |
517 | ((IDisposable)HTTPClient).Dispose(); |
|
489 | } |
518 | } |
|
490 | } |
519 | } |