Add resume capability to GetTempFile

This commit is contained in:
LukePulverenti
2013-03-14 15:52:53 -04:00
parent a7f06c84b1
commit fe1834e6be
10 changed files with 219 additions and 119 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Threading;
namespace MediaBrowser.Common.Net
{
/// <summary>
/// Class HttpRequestOptions
/// </summary>
public class HttpRequestOptions
{
/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>The URL.</value>
public string Url { get; set; }
/// <summary>
/// Gets or sets the cancellation token.
/// </summary>
/// <value>The cancellation token.</value>
public CancellationToken CancellationToken { get; set; }
/// <summary>
/// Gets or sets the resource pool.
/// </summary>
/// <value>The resource pool.</value>
public SemaphoreSlim ResourcePool { get; set; }
/// <summary>
/// Gets or sets the user agent.
/// </summary>
/// <value>The user agent.</value>
public string UserAgent { get; set; }
/// <summary>
/// Gets or sets the max resume count.
/// </summary>
/// <value>The max resume count.</value>
public int MaxResumeCount { get; set; }
/// <summary>
/// Gets or sets the progress.
/// </summary>
/// <value>The progress.</value>
public IProgress<double> Progress { get; set; }
}
}

View File

@@ -49,29 +49,15 @@ namespace MediaBrowser.Common.Net
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{Stream}.</returns>
Task<Stream> Post(string url, Dictionary<string, string> postData, CancellationToken cancellationToken);
/// <summary>
/// Downloads the contents of a given url into a temporary location
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <param name="userAgent">The user agent.</param>
/// <param name="options">The options.</param>
/// <returns>Task{System.String}.</returns>
/// <exception cref="System.ArgumentNullException">progress</exception>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
Task<string> GetTempFile(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null);
/// <summary>
/// Gets the temp file.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <param name="userAgent">The user agent.</param>
/// <returns>Task{System.String}.</returns>
Task<string> GetTempFile(string url, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null);
Task<string> GetTempFile(HttpRequestOptions options);
/// <summary>
/// Downloads the contents of a given url into a MemoryStream