using System;
using System.Collections.Generic;
using System.Threading;
namespace MediaBrowser.Common.Net
{
///
/// Class HttpRequestOptions
///
public class HttpRequestOptions
{
///
/// Gets or sets the URL.
///
/// The URL.
public string Url { get; set; }
///
/// Gets or sets the accept header.
///
/// The accept header.
public string AcceptHeader
{
get { return GetHeaderValue("Accept"); }
set
{
RequestHeaders["Accept"] = value;
}
}
///
/// Gets or sets the cancellation token.
///
/// The cancellation token.
public CancellationToken CancellationToken { get; set; }
///
/// Gets or sets the resource pool.
///
/// The resource pool.
public SemaphoreSlim ResourcePool { get; set; }
///
/// Gets or sets the user agent.
///
/// The user agent.
public string UserAgent
{
get { return GetHeaderValue("User-Agent"); }
set
{
RequestHeaders["User-Agent"] = value;
}
}
///
/// Gets or sets the progress.
///
/// The progress.
public IProgress Progress { get; set; }
///
/// Gets or sets a value indicating whether [enable HTTP compression].
///
/// true if [enable HTTP compression]; otherwise, false.
public bool EnableHttpCompression { get; set; }
public Dictionary RequestHeaders { get; private set; }
public string RequestContentType { get; set; }
public string RequestContent { get; set; }
public byte[] RequestContentBytes { get; set; }
public bool BufferContent { get; set; }
public bool LogRequest { get; set; }
public bool LogErrorResponseBody { get; set; }
public HttpRequestCachePolicy CachePolicy { get; set; }
private string GetHeaderValue(string name)
{
string value;
RequestHeaders.TryGetValue(name, out value);
return value;
}
///
/// Initializes a new instance of the class.
///
public HttpRequestOptions()
{
EnableHttpCompression = true;
BufferContent = true;
CachePolicy = HttpRequestCachePolicy.None;
RequestHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase);
LogRequest = true;
}
}
public enum HttpRequestCachePolicy
{
None = 1,
Validate = 2
}
}