hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Interactive CredentialsProvider
Date Fri, 14 Oct 2011 19:14:23 GMT
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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message