-
Enhancement
-
Resolution: Done
-
Major
-
2.3-beta-1
-
None
-
None
A particular use case that arose in the course of RESTEASY-516 (upgrading to HttpClient (4.x)) is the need to configure BASIC authentication. Here is an example:
static private ClientExecutor createAuthenticatingExecutor(DefaultHttpClient client) { // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); HttpHost targetHost = new HttpHost("localhost", 8081); authCache.put(targetHost, basicAuth); // Add AuthCache to the execution context BasicHttpContext localContext = new BasicHttpContext(); localContext.setAttribute(ClientContext.AUTH_CACHE, authCache); // Create ClientExecutor. ApacheHttpClient4Executor executor = new ApacheHttpClient4Executor(client, localContext); return executor; }
ApacheHttpClient4Executor gets a new constructor, a getter, and a setter.