2013-02-24 17:13:45 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.Net
|
|
|
|
|
{
|
2013-02-25 20:43:04 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interface IHttpClient
|
|
|
|
|
/// </summary>
|
2013-02-24 17:13:45 -07:00
|
|
|
|
public interface IHttpClient : IDisposable
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs a GET request and returns the resulting stream
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
|
/// <param name="resourcePool">The resource pool.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task{Stream}.</returns>
|
|
|
|
|
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
|
|
|
|
Task<Stream> Get(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
|
|
|
|
|
|
2013-03-02 22:25:42 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task{Stream}.</returns>
|
|
|
|
|
Task<Stream> Get(string url, CancellationToken cancellationToken);
|
2013-05-03 21:07:27 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified options.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="options">The options.</param>
|
|
|
|
|
/// <returns>Task{Stream}.</returns>
|
|
|
|
|
Task<Stream> Get(HttpRequestOptions options);
|
|
|
|
|
|
2013-02-24 17:13:45 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs a POST request
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
|
/// <param name="postData">Params to add to the POST data.</param>
|
|
|
|
|
/// <param name="resourcePool">The resource pool.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>stream on success, null on failure</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException">postData</exception>
|
|
|
|
|
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
|
|
|
|
Task<Stream> Post(string url, Dictionary<string, string> postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
|
|
|
|
|
|
2013-03-02 22:25:42 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Posts the specified URL.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
|
/// <param name="postData">The post data.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task{Stream}.</returns>
|
|
|
|
|
Task<Stream> Post(string url, Dictionary<string, string> postData, CancellationToken cancellationToken);
|
2013-03-14 12:52:53 -07:00
|
|
|
|
|
2013-02-24 17:13:45 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Downloads the contents of a given url into a temporary location
|
|
|
|
|
/// </summary>
|
2013-03-14 12:52:53 -07:00
|
|
|
|
/// <param name="options">The options.</param>
|
2013-02-24 17:13:45 -07:00
|
|
|
|
/// <returns>Task{System.String}.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException">progress</exception>
|
|
|
|
|
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
|
2013-03-14 12:52:53 -07:00
|
|
|
|
Task<string> GetTempFile(HttpRequestOptions options);
|
2013-02-24 17:13:45 -07:00
|
|
|
|
}
|
|
|
|
|
}
|