// Public members public static void CopyTo(this IHttpWebRequestOptions options, IHttpWebRequest httpWebRequest, bool copyIfNull = true) { if (copyIfNull || !string.IsNullOrEmpty(options.Accept)) { httpWebRequest.Accept = options.Accept; } if (copyIfNull || !string.IsNullOrEmpty(options.AcceptLanguage)) { httpWebRequest.Headers[HttpRequestHeader.AcceptLanguage] = options.AcceptLanguage; } httpWebRequest.AutomaticDecompression = options.AutomaticDecompression; if (copyIfNull || !(options.Cookies is null)) { httpWebRequest.CookieContainer = options.Cookies; } if (copyIfNull || !(options.Credentials is null)) { httpWebRequest.Credentials = options.Credentials; } if (copyIfNull || !(options.Proxy is null)) { httpWebRequest.Proxy = options.Proxy; } if (copyIfNull || !string.IsNullOrEmpty(options.UserAgent)) { httpWebRequest.UserAgent = options.UserAgent; } }
public static void CopyTo(this IHttpWebRequestOptions options, HttpWebRequestOptions other, bool copyIfNull = true) { if (copyIfNull || !string.IsNullOrEmpty(options.Accept)) { other.Accept = options.Accept; } if (copyIfNull || !string.IsNullOrEmpty(options.AcceptLanguage)) { other.AcceptLanguage = options.AcceptLanguage; } other.AutomaticDecompression = options.AutomaticDecompression; if (copyIfNull || !(options.Cookies is null)) { other.Cookies = options.Cookies; } if (copyIfNull || !(options.Credentials is null)) { other.Credentials = options.Credentials; } if (copyIfNull || !(options.Proxy is null)) { other.Proxy = options.Proxy; } if (copyIfNull || !string.IsNullOrEmpty(options.UserAgent)) { other.UserAgent = options.UserAgent; } }
public static HttpWebRequestOptions Combine(IHttpWebRequestOptions options1, IHttpWebRequestOptions options2, bool copyIfNull = true) { HttpWebRequestOptions result = new HttpWebRequestOptions(options1); result.Combine(options2, copyIfNull); return(result); }
protected HttpWebRequestFactoryBase(IHttpWebRequestOptions options) { if (options is null) { throw new ArgumentNullException(nameof(options)); } this.options = options; }
public HttpWebRequestOptionsFactory(IHttpWebRequestOptions webRequestOptions) { if (webRequestOptions is null) { throw new ArgumentNullException(nameof(webRequestOptions)); } this.defaultWebRequestOptions = webRequestOptions; }
public static void CopyTo(this IHttpWebRequestOptions options, WebClient webClient) { webClient.Headers[HttpRequestHeader.Accept] = options.Accept; webClient.Headers[HttpRequestHeader.AcceptLanguage] = options.AcceptLanguage; //webClient.AutomaticDecompression = options.AutomaticDecompression; //webClient.CookieContainer = options.Cookies; webClient.Credentials = options.Credentials; webClient.Proxy = options.Proxy; webClient.Headers[HttpRequestHeader.UserAgent] = options.UserAgent; }
public CurlHttpWebRequestFactory(IHttpWebRequestOptions options) { if (File.Exists(LibCurl.LibCurlPath) || !File.Exists(LibCurl.CurlExecutablePath)) { webRequestFactory = new LibCurlHttpWebRequestFactory(options); } else { webRequestFactory = new BinCurlHttpWebRequestFactory(options); } }
public static IWebClient WithOptions(this IWebClient client, IHttpWebRequestOptions options) { client.Headers[HttpRequestHeader.Accept] = options.Accept; client.Headers[HttpRequestHeader.AcceptLanguage] = options.AcceptLanguage; //webClient.AutomaticDecompression = options.AutomaticDecompression; //webClient.CookieContainer = options.Cookies; client.Credentials = options.Credentials; client.Proxy = options.Proxy; client.Headers[HttpRequestHeader.UserAgent] = options.UserAgent; return(client); }
// Private members private void Combine(IHttpWebRequestOptions other, bool copyIfNull = true) { if (copyIfNull || !string.IsNullOrWhiteSpace(other.Accept)) { Accept = other.Accept; } if (copyIfNull || !string.IsNullOrWhiteSpace(other.AcceptLanguage)) { AcceptLanguage = other.AcceptLanguage; } if (copyIfNull || other.AllowAutoRedirect.HasValue) { AllowAutoRedirect = other.AllowAutoRedirect; } if (copyIfNull || other.AutomaticDecompression != DecompressionMethods.None) { AutomaticDecompression = other.AutomaticDecompression; } if (copyIfNull || other.Cookies is object) { Cookies = other.Cookies; } if (copyIfNull || other.Credentials is object) { Credentials = other.Credentials; } if (Headers is null) { Headers = other.Headers.Clone(); } else if (other.Headers is object) { other.Headers.CopyTo(Headers); } if (copyIfNull || other.Proxy is object) { Proxy = other.Proxy; } if (copyIfNull || !string.IsNullOrWhiteSpace(other.UserAgent)) { UserAgent = other.UserAgent; } }
public void SetOptions(string domain, IHttpWebRequestOptions options) { lock (uriOptionsMutex) { IHttpWebRequestOptions uriOptions = FindOptionsByUri(domain); if (!(uriOptions is null)) { this.uriOptions.RemoveAll(item => item.Options == uriOptions); } // Allow the user to just clear the existing options if a null argument is given. if (!(options is null)) { this.uriOptions.Add(new UriOptions(domain, options)); } } }
public BinCurlHttpWebRequestFactory(IHttpWebRequestOptions options) : this(new HttpWebRequestOptionsFactory(options)) { }
public static HttpWebRequest WithOptions(this HttpWebRequest httpWebRequest, IHttpWebRequestOptions options, bool copyIfNull = true) { WithOptions(new HttpWebRequestAdapter(httpWebRequest), options, copyIfNull); return(httpWebRequest); }
public static IHttpWebRequest WithOptions(this IHttpWebRequest httpWebRequest, IHttpWebRequestOptions options, bool copyIfNull = true) { if (copyIfNull || !string.IsNullOrWhiteSpace(options.Accept)) { httpWebRequest.Accept = options.Accept; } if (copyIfNull || !string.IsNullOrWhiteSpace(options.AcceptLanguage)) { httpWebRequest.Headers[HttpRequestHeader.AcceptLanguage] = options.AcceptLanguage; } if (copyIfNull || options.AllowAutoRedirect.HasValue) { httpWebRequest.AllowAutoRedirect = options.AllowAutoRedirect ?? httpWebRequest.AllowAutoRedirect; } httpWebRequest.AutomaticDecompression = options.AutomaticDecompression; if (copyIfNull || options.Cookies is object) { httpWebRequest.CookieContainer = options.Cookies; } if (copyIfNull || options.Credentials is object) { httpWebRequest.Credentials = options.Credentials; } if (httpWebRequest.Headers is object && options.Headers is object) { httpWebRequest.WithHeaders(options.Headers); } if (copyIfNull || options.Proxy is object) { httpWebRequest.Proxy = options.Proxy; } if (copyIfNull || !string.IsNullOrWhiteSpace(options.UserAgent)) { httpWebRequest.UserAgent = options.UserAgent; } return(httpWebRequest); }
public OptionsInfo(IHttpWebRequestOptions webRequestOptions, bool copyIfNull) { WebRequestOptions = webRequestOptions; CopyIfNull = copyIfNull; }
public void Add(Uri endpoint, IHttpWebRequestOptions options, bool copyIfNull = true) { lock (webRequestOptions) webRequestOptions[endpoint] = new OptionsInfo(options, copyIfNull); }
public BinCurlHttpWebRequestFactory(IHttpWebRequestOptions options, string curlExecutablePath) : this(options) { this.curlExecutablePath = curlExecutablePath; }
public UriOptions(string domain, IHttpWebRequestOptions options) { this.Domain = domain; this.Options = options; }
public void SetOptions(IHttpWebRequestOptions options) { this.options = options; }
public void SetOptions(string domain, IHttpWebRequestOptions options) { webRequestFactory.SetOptions(domain, options); }
public void SetOptions(IHttpWebRequestOptions options) { webRequestFactory.SetOptions(options); }
public static WebClient WithOptions(this WebClient client, IHttpWebRequestOptions options) { WithOptions(new WebClientAdapter(client), options); return(client); }
public BinCurlHttpWebRequestFactory(IHttpWebRequestOptions options, ICurlWebRequestOptions curlOptions) : this(new HttpWebRequestOptionsFactory(options), curlOptions) { }
public HttpWebRequestOptions(IHttpWebRequestOptions other, bool copyIfNull = true) { other.CopyTo(this, copyIfNull); }
public LibCurlHttpWebRequestFactory(IHttpWebRequestOptions options) : base(options) { }
public HttpWebRequestOptions(IHttpWebRequestOptions other, bool copyIfNull = true) { Combine(other, copyIfNull); }