src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AuthenticationFilter.java
equal
deleted
inserted
replaced
41 |
41 |
42 /** |
42 /** |
43 * Implementation of Http Basic authentication. |
43 * Implementation of Http Basic authentication. |
44 */ |
44 */ |
45 class AuthenticationFilter implements HeaderFilter { |
45 class AuthenticationFilter implements HeaderFilter { |
46 volatile MultiExchange<?,?> exchange; |
46 volatile MultiExchange<?> exchange; |
47 private static final Base64.Encoder encoder = Base64.getEncoder(); |
47 private static final Base64.Encoder encoder = Base64.getEncoder(); |
48 |
48 |
49 static final int DEFAULT_RETRY_LIMIT = 3; |
49 static final int DEFAULT_RETRY_LIMIT = 3; |
50 |
50 |
51 static final int retry_limit = Utils.getIntegerNetProperty( |
51 static final int retry_limit = Utils.getIntegerNetProperty( |
106 throw new InternalError(e); |
106 throw new InternalError(e); |
107 } |
107 } |
108 } |
108 } |
109 |
109 |
110 @Override |
110 @Override |
111 public void request(HttpRequestImpl r, MultiExchange<?,?> e) throws IOException { |
111 public void request(HttpRequestImpl r, MultiExchange<?> e) throws IOException { |
112 // use preemptive authentication if an entry exists. |
112 // use preemptive authentication if an entry exists. |
113 Cache cache = getCache(e); |
113 Cache cache = getCache(e); |
114 this.exchange = e; |
114 this.exchange = e; |
115 |
115 |
116 // Proxy |
116 // Proxy |
261 |
261 |
262 // Use a WeakHashMap to make it possible for the HttpClient to |
262 // Use a WeakHashMap to make it possible for the HttpClient to |
263 // be garbaged collected when no longer referenced. |
263 // be garbaged collected when no longer referenced. |
264 static final WeakHashMap<HttpClientImpl,Cache> caches = new WeakHashMap<>(); |
264 static final WeakHashMap<HttpClientImpl,Cache> caches = new WeakHashMap<>(); |
265 |
265 |
266 static synchronized Cache getCache(MultiExchange<?,?> exchange) { |
266 static synchronized Cache getCache(MultiExchange<?> exchange) { |
267 HttpClientImpl client = exchange.client(); |
267 HttpClientImpl client = exchange.client(); |
268 Cache c = caches.get(client); |
268 Cache c = caches.get(client); |
269 if (c == null) { |
269 if (c == null) { |
270 c = new Cache(); |
270 c = new Cache(); |
271 caches.put(client, c); |
271 caches.put(client, c); |