Exemple #1
0
        public override HttpMessageHandler CreateHttpMessageHandler(Uri uri, HttpClientSettings settings)
        {
            var proxy         = WebRequestHelper.ProxyCache.GetProxy(uri);
            var clientHandler = new DefaultHttpClientHandler(proxy, settings);

            HttpMessageHandler messageHandler = clientHandler;

            if (proxy != null)
            {
                messageHandler = new ProxyAuthenticationHandler(clientHandler, HttpClientProvider.CredentialService, WebRequestHelper.ProxyCache)
                {
                    NonInteractive = settings.NonInteractive
                };
            }

            if (settings.SourceAuthenticationRequired)
            {
                var innerHandler = messageHandler;

                messageHandler = new HttpSourceAuthenticationHandler(uri, clientHandler, HttpClientProvider.CredentialService)
                {
                    InnerHandler = innerHandler
                };
            }

            return(messageHandler);
        }
Exemple #2
0
 public DefaultHttpClientHandler(IWebProxy proxy, HttpClientSettings settings)
 {
     AllowAutoRedirect      = settings.AllowAutoRedirect;
     AutomaticDecompression = settings.AutomaticDecompression;
     PreAuthenticate        = settings.PreAuthenticate;
     Proxy = proxy;
 }
 public abstract HttpMessageHandler CreateHttpMessageHandler(Uri uri, HttpClientSettings settings);
 public static HttpMessageHandler CreateHttpMessageHandler(Uri uri, HttpClientSettings settings)
 {
     return(httpMessageHandlerProvider.CreateHttpMessageHandler(uri, settings ?? defaultHttpClientSettings));
 }
        public static HttpClient CreateHttpClient(Uri uri, HttpClientSettings settings)
        {
            var handler = CreateHttpMessageHandler(uri, settings);

            return(new HttpClient(handler));
        }
 public static HttpClient CreateHttpClient(string uri, HttpClientSettings settings)
 {
     return(CreateHttpClient(new Uri(uri), settings));
 }