From 045c740f3a6f8811c10a4157069c533d29fcbea6 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 1 Mar 2011 11:17:48 +0000 Subject: [PATCH] Code optimization: perform auth cache lookup only if no auth scheme is available in the auth state git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1075780 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/client/protocol/RequestAuthCache.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java index 4ca24c126..cc8da8910 100644 --- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java +++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java @@ -83,7 +83,7 @@ public class RequestAuthCache implements HttpRequestInterceptor { HttpHost target = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); AuthState targetState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); - if (target != null && targetState != null) { + if (target != null && targetState != null && targetState.getAuthScheme() == null) { AuthScheme authScheme = authCache.get(target); if (authScheme != null) { doPreemptiveAuth(target, authScheme, targetState, credsProvider); @@ -92,7 +92,7 @@ public class RequestAuthCache implements HttpRequestInterceptor { HttpHost proxy = (HttpHost) context.getAttribute(ExecutionContext.HTTP_PROXY_HOST); AuthState proxyState = (AuthState) context.getAttribute(ClientContext.PROXY_AUTH_STATE); - if (proxy != null && proxyState != null) { + if (proxy != null && proxyState != null && proxyState.getAuthScheme() == null) { AuthScheme authScheme = authCache.get(proxy); if (authScheme != null) { doPreemptiveAuth(proxy, authScheme, proxyState, credsProvider);