hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1175377 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
Date Sun, 25 Sep 2011 12:25:07 GMT
Author: olegk
Date: Sun Sep 25 12:25:07 2011
New Revision: 1175377

URL: http://svn.apache.org/viewvc?rev=1175377&view=rev
Log:
HTTPCLIENT-1107: auth framework redesign

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java?rev=1175377&r1=1175376&r2=1175377&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
Sun Sep 25 12:25:07 2011
@@ -40,6 +40,8 @@ import org.apache.http.auth.AuthScheme;
 import org.apache.http.auth.AuthState;
 import org.apache.http.client.AuthCache;
 import org.apache.http.client.params.AuthPolicy;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.client.BasicAuthCache;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
@@ -75,6 +77,13 @@ public class ResponseAuthCache implement
         AuthState targetState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
         if (target != null && targetState != null) {
             if (isCachable(targetState)) {
+                if (target.getPort() < 0) {
+                    SchemeRegistry schemeRegistry = (SchemeRegistry) context.getAttribute(
+                            ClientContext.SCHEME_REGISTRY);
+                    Scheme scheme = schemeRegistry.getScheme(target);
+                    target = new HttpHost(target.getHostName(),
+                            scheme.resolvePort(target.getPort()), target.getSchemeName());
+                }
                 if (authCache == null) {
                     authCache = new BasicAuthCache();
                     context.setAttribute(ClientContext.AUTH_CACHE, authCache);



Mime
View raw message