IHttpClient.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /// Gets the response.
  15. /// </summary>
  16. /// <param name="options">The options.</param>
  17. /// <returns>Task{HttpResponseInfo}.</returns>
  18. Task<HttpResponseInfo> GetResponse(HttpRequestOptions options);
  19. /// <summary>
  20. /// Performs a GET request and returns the resulting stream
  21. /// </summary>
  22. /// <param name="url">The URL.</param>
  23. /// <param name="resourcePool">The resource pool.</param>
  24. /// <param name="cancellationToken">The cancellation token.</param>
  25. /// <returns>Task{Stream}.</returns>
  26. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  27. Task<Stream> Get(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
  28. /// <summary>
  29. /// Gets the specified URL.
  30. /// </summary>
  31. /// <param name="url">The URL.</param>
  32. /// <param name="cancellationToken">The cancellation token.</param>
  33. /// <returns>Task{Stream}.</returns>
  34. Task<Stream> Get(string url, CancellationToken cancellationToken);
  35. /// <summary>
  36. /// Gets the specified options.
  37. /// </summary>
  38. /// <param name="options">The options.</param>
  39. /// <returns>Task{Stream}.</returns>
  40. Task<Stream> Get(HttpRequestOptions options);
  41. /// <summary>
  42. /// Performs a POST request
  43. /// </summary>
  44. /// <param name="url">The URL.</param>
  45. /// <param name="postData">Params to add to the POST data.</param>
  46. /// <param name="resourcePool">The resource pool.</param>
  47. /// <param name="cancellationToken">The cancellation token.</param>
  48. /// <returns>stream on success, null on failure</returns>
  49. /// <exception cref="System.ArgumentNullException">postData</exception>
  50. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  51. Task<Stream> Post(string url, Dictionary<string, string> postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
  52. /// <summary>
  53. /// Posts the specified URL.
  54. /// </summary>
  55. /// <param name="url">The URL.</param>
  56. /// <param name="postData">The post data.</param>
  57. /// <param name="cancellationToken">The cancellation token.</param>
  58. /// <returns>Task{Stream}.</returns>
  59. Task<Stream> Post(string url, Dictionary<string, string> postData, CancellationToken cancellationToken);
  60. /// <summary>
  61. /// Posts the specified options with post data
  62. /// </summary>
  63. /// <param name="options">The options</param>
  64. /// <param name="postData">The post data</param>
  65. /// <returns>Task{Stream}</returns>
  66. Task<Stream> Post(HttpRequestOptions options, Dictionary<string, string> postData);
  67. /// <summary>
  68. /// Posts the specified options.
  69. /// </summary>
  70. /// <param name="options">The options.</param>
  71. /// <returns>Task{HttpResponseInfo}.</returns>
  72. Task<HttpResponseInfo> Post(HttpRequestOptions options);
  73. /// <summary>
  74. /// Downloads the contents of a given url into a temporary location
  75. /// </summary>
  76. /// <param name="options">The options.</param>
  77. /// <returns>Task{System.String}.</returns>
  78. /// <exception cref="System.ArgumentNullException">progress</exception>
  79. /// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
  80. Task<string> GetTempFile(HttpRequestOptions options);
  81. /// <summary>
  82. /// Gets the temporary file response.
  83. /// </summary>
  84. /// <param name="options">The options.</param>
  85. /// <returns>Task{HttpResponseInfo}.</returns>
  86. Task<HttpResponseInfo> GetTempFileResponse(HttpRequestOptions options);
  87. }
  88. }