Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-619

ApacheHttpClient4Executor should be configurable with an HttpContext

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 2.3-RC1
    • 2.3-beta-1
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

            rsigal@redhat.com Ronald Sigal
            rsigal@redhat.com Ronald Sigal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: