Esempio n. 1
0
        /// <summary>
        /// Constructor that instaciates the internal <see cref="HttpClient"/> with a custom
        /// <see cref="HttpClientHandler"/>
        /// </summary>
        /// <param name="httpClientHandler"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public HttpHandler(HttpClientHandler httpClientHandler)
        {
            if (httpClientHandler.IsNull())
            {
                throw new ArgumentNullException(nameof(httpClientHandler));
            }

            _client = new HttpClient(httpClientHandler);
        }
Esempio n. 2
0
 public static HttpClient CreateHttpClient(this Public Public, HttpClientHandler handler = null)
 {
     if (UseProxy)
     {
         var proxy = Actor.Public.GetService <IHttpProxyFactory>().BuildProxy();
         if (handler.IsNull())
         {
             handler = new HttpClientHandler();
         }
         handler.Proxy = proxy;
         return(new HttpClient(handler));
     }
     else
     {
         return(handler.IsNotNull() ? new HttpClient(handler) : new HttpClient());
     }
 }