IHttpClient.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Common.Net
  7. {
  8. /// <summary>
  9. /// Interface IHttpClient
  10. /// </summary>
  11. public interface IHttpClient : IDisposable
  12. {
  13. /// <summary>
  14. /// Performs a GET request and returns the resulting stream
  15. /// </summary>
  16. /// <param name="url">The URL.</param>
  17. /// <param name="resourcePool">The resource pool.</param>
  18. /// <param name="cancellationToken">The cancellation token.</param>
  19. /// <returns>Task{Stream}.</returns>
  20. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  21. Task<Stream> Get(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
  22. /// <summary>
  23. /// Performs a POST request
  24. /// </summary>
  25. /// <param name="url">The URL.</param>
  26. /// <param name="postData">Params to add to the POST data.</param>
  27. /// <param name="resourcePool">The resource pool.</param>
  28. /// <param name="cancellationToken">The cancellation token.</param>
  29. /// <returns>stream on success, null on failure</returns>
  30. /// <exception cref="System.ArgumentNullException">postData</exception>
  31. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  32. Task<Stream> Post(string url, Dictionary<string, string> postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
  33. /// <summary>
  34. /// Downloads the contents of a given url into a temporary location
  35. /// </summary>
  36. /// <param name="url">The URL.</param>
  37. /// <param name="resourcePool">The resource pool.</param>
  38. /// <param name="cancellationToken">The cancellation token.</param>
  39. /// <param name="progress">The progress.</param>
  40. /// <param name="userAgent">The user agent.</param>
  41. /// <returns>Task{System.String}.</returns>
  42. /// <exception cref="System.ArgumentNullException">progress</exception>
  43. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  44. Task<string> GetTempFile(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null);
  45. /// <summary>
  46. /// Downloads the contents of a given url into a MemoryStream
  47. /// </summary>
  48. /// <param name="url">The URL.</param>
  49. /// <param name="resourcePool">The resource pool.</param>
  50. /// <param name="cancellationToken">The cancellation token.</param>
  51. /// <returns>Task{MemoryStream}.</returns>
  52. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  53. Task<MemoryStream> GetMemoryStream(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
  54. }
  55. }