#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.Net.Http.Headers;
namespace MediaBrowser.Common.Net
{
///
/// Class HttpRequestOptions.
///
public class HttpRequestOptions
{
///
/// Initializes a new instance of the class.
///
public HttpRequestOptions()
{
RequestHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase);
CacheMode = CacheMode.None;
DecompressionMethod = CompressionMethods.Deflate;
}
///
/// Gets or sets the URL.
///
/// The URL.
public string Url { get; set; }
public CompressionMethods DecompressionMethod { get; set; }
///
/// Gets or sets the accept header.
///
/// The accept header.
public string AcceptHeader
{
get => GetHeaderValue(HeaderNames.Accept);
set => RequestHeaders[HeaderNames.Accept] = value;
}
///
/// Gets or sets the cancellation token.
///
/// The cancellation token.
public CancellationToken CancellationToken { get; set; }
///
/// Gets or sets the user agent.
///
/// The user agent.
public string UserAgent
{
get => GetHeaderValue(HeaderNames.UserAgent);
set => RequestHeaders[HeaderNames.UserAgent] = value;
}
///
/// Gets or sets the referrer.
///
/// The referrer.
public string Referer
{
get => GetHeaderValue(HeaderNames.Referer);
set => RequestHeaders[HeaderNames.Referer] = value;
}
///
/// Gets or sets the host.
///
/// The host.
public string Host
{
get => GetHeaderValue(HeaderNames.Host);
set => RequestHeaders[HeaderNames.Host] = value;
}
public Dictionary RequestHeaders { get; private set; }
public string RequestContentType { get; set; }
public string RequestContent { get; set; }
public bool BufferContent { get; set; }
public bool LogErrorResponseBody { get; set; }
public bool EnableKeepAlive { get; set; }
public CacheMode CacheMode { get; set; }
public TimeSpan CacheLength { get; set; }
public bool EnableDefaultUserAgent { get; set; }
private string GetHeaderValue(string name)
{
RequestHeaders.TryGetValue(name, out var value);
return value;
}
}
}