Florent Georges wrote:
Oleg Kalnichevski wrote:
Florent Georges wrote:
Hi,
I use client.getCredentialsProvider() to set credentials
for Basic or Digest authentication. So for now, the scope of
the credential settings are the Http Client. But I would
like they have the scope of one single request instead. Is
it possible?
You can create a new local context for each request and bind an
instance specific CredentialsProvider to it.
Thanks for the answer. Actually, in between, I used the other
way around. The credentials must be set for one single request,
and cookies must survive among several requests, so I create one
CookieStore and instantiate a new HTTP client for each request
(each one bound to the same cookie store.)
Is there a big difference between this approach and what you
suggested (if I am right, using the same client but a different
context for each request) ?
If you are creating a new connection manager for each request, this
effectively prevents HttpClient from re-using persistent connections.
Moreover, if you do not shut down connection manager after each request,
you are leaving it up to the garbage collector to close persistent
connections and deallocate system resources. Thus, open onnections can
pile up increasing the risk of running out of system resources.
Oleg
Are there any other info that would
be shared using the same client? What I like in my approach is
that I control exactly what is shared between every requests,
instead of declaring what shouldn't be shared...
Regards,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]