mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-15 06:26:37 +00:00
HTTPCLIENT-1107: auth framework redesign
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1175377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e5d83200fd
commit
c4d1599bd0
@ -40,6 +40,8 @@
|
||||
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 void process(final HttpResponse response, final HttpContext context)
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user