I'm working on an application where all the requests to the
server much be authenticated.  I'd like to use the
Client.get()/etc. methods but to associated the ChallengeResponse
instance with the request, I need to use the Client.handle
method.

I've successfully done this another way by doing:


     Client client = new Client(new
Context(),config.getServerLocation().getSchemeProtocol()) {
        public void handle(Request request,Response response) {
           request.setChallengeResponse(new
ChallengeResponse(ChallengeScheme.HTTP_BASIC,"user","pass"));
           super.handle(request,response);
        }
     };

This way I can now call client.get("http://www.somewhere.com";) and get
a result without a 401 response.

Now, is there a better way?

The above seems a bit awkward.

I could image constructing a Client instance with the ChallengeResponse
instance or subclassing Client to create AuthenticatedClient.  Similarly,
I could see the need to track and send session information (e.g. cookies).

Are there helper classes for doing this as a client?

--Alex Milowski

Reply via email to