On Fri, 2011-10-14 at 08:19 -0700, AlexanderKitaev wrote: > Hello! > > I have encountered the following problem: > > Request is sent and receives 401 back with keep-alive enabled and keep-alive > timeout set to 15 seconds: > > 401 HTTP ... > Keep-Alive: true > Connection: keep-alive=15 ... > > Then my custom CredentialsProvider implementation is called and it may take > more than 15 seconds to retrieve credentials. > > Then, HttpClient attempts to reuse existing connection > (SingleClientConnManager is used). It manages to send request with > credentials obtained from provider, but fails to read response, because > server already closed this very connection due to the keep-alive timeout. > > Is there a way to avoid such situation and to let CredentialsProvider work > as long as necessary? > > Thanks!
Let the first exchange fail, prompt user for credentials, update credential provider with new credentials, and retry the request. Here's an example you can take a look at http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientInteractiveAuthentication.java Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
