View RSS Feed

Apache Commons

Preemptive Authentication

Rate this Entry
by , 02-24-2012 at 08:03 PM (2254 Views)
Within HttpClient, preemptive authentication can be enabled. HttpClient sends the response of basic authentication before unauthorized is given by server, in preemptive authentication mode. This will be reducing overhead for connection making.
To enable it, use this code.
Java Code:
For preemptive authentication, default credentials are required to be set for proxy host or target. Preemptive authentication will become ineffective in case default credentials are not been provided.
This process is explained by given code.
Java Code:
Credentials defaultcreds = new UsernamePasswordCredentials("username", "password");
client.getState().setCredentials(new AuthScope("myhost", 80, AuthScope.ANY_REALM), defaultcreds);

Submit "Preemptive Authentication" to Facebook Submit "Preemptive Authentication" to Digg Submit "Preemptive Authentication" to Submit "Preemptive Authentication" to StumbleUpon Submit "Preemptive Authentication" to Google