/// <exception cref="Apache.Http.HttpException"></exception> /// <exception cref="System.IO.IOException"></exception> public virtual void Process(IHttpRequest request, HttpContext context) { Args.NotNull(request, "HTTP request"); Args.NotNull(context, "HTTP context"); HttpClientContext clientContext = ((HttpClientContext)HttpClientContext.Adapt(context )); AuthCache authCache = clientContext.GetAuthCache(); if (authCache == null) { this.log.Debug("Auth cache not set in the context"); return; } CredentialsProvider credsProvider = clientContext.GetCredentialsProvider(); if (credsProvider == null) { this.log.Debug("Credentials provider not set in the context"); return; } RouteInfo route = clientContext.GetHttpRoute(); HttpHost target = clientContext.GetTargetHost(); if (target.GetPort() < 0) { target = new HttpHost(target.GetHostName(), route.GetTargetHost().GetPort(), target .GetSchemeName()); } AuthState targetState = clientContext.GetTargetAuthState(); if (targetState != null && targetState.GetState() == AuthProtocolState.Unchallenged) { AuthScheme authScheme = authCache.Get(target); if (authScheme != null) { DoPreemptiveAuth(target, authScheme, targetState, credsProvider); } } HttpHost proxy = route.GetProxyHost(); AuthState proxyState = clientContext.GetProxyAuthState(); if (proxy != null && proxyState != null && proxyState.GetState() == AuthProtocolState .Unchallenged) { AuthScheme authScheme = authCache.Get(proxy); if (authScheme != null) { DoPreemptiveAuth(proxy, authScheme, proxyState, credsProvider); } } }