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
This commit is contained in:
Oleg Kalnichevski 2011-03-01 11:17:48 +00:00
parent 9d55aee86f
commit 045c740f3a
1 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ public class RequestAuthCache implements HttpRequestInterceptor {
HttpHost target = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); HttpHost target = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
AuthState targetState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); 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); AuthScheme authScheme = authCache.get(target);
if (authScheme != null) { if (authScheme != null) {
doPreemptiveAuth(target, authScheme, targetState, credsProvider); doPreemptiveAuth(target, authScheme, targetState, credsProvider);
@ -92,7 +92,7 @@ public class RequestAuthCache implements HttpRequestInterceptor {
HttpHost proxy = (HttpHost) context.getAttribute(ExecutionContext.HTTP_PROXY_HOST); HttpHost proxy = (HttpHost) context.getAttribute(ExecutionContext.HTTP_PROXY_HOST);
AuthState proxyState = (AuthState) context.getAttribute(ClientContext.PROXY_AUTH_STATE); 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); AuthScheme authScheme = authCache.get(proxy);
if (authScheme != null) { if (authScheme != null) {
doPreemptiveAuth(proxy, authScheme, proxyState, credsProvider); doPreemptiveAuth(proxy, authScheme, proxyState, credsProvider);