On Thu, 2011-09-08 at 16:06 +0100, Sam Crawford wrote:
> I've not used the UserToken class myself (and don't have a readily
> available test environment), but if the approach you've got isn't
> working (what do the ConnPoolByRoute logs show?) then from reading the
> docs I'd suggest you have two options:
> 
> 1. Do it as per 7.2.2.1 on
> http://hc.apache.org/httpcomponents-client-ga/tutorial/html/advanced.html.
> i.e. Run the first request without setting the UserToken, pull it from
> the context after the response, and then reuse it forever more.
> 2. Reuse the same HttpContext across all requests (although you'll
> want to be careful in a multi-threaded setup of course).
> 
> Thanks,
> 
> Sam
> 

Thomas and Sam,

It is all quite simple. There is no way of knowing for HttpClient that
requests are logically related and share the same user identity per
default. One must use the _same_ HttpContext instance in order to inform
HttpClient that requests are logically related and belong to the same
user. Once a user token is bound to the context HttpClient will
automatically use the token when obtaining connections from the pool.
Without the token the pool manager cannot lease connections that carry a
state and will have to create a new connection instead of re-using
persistent connections from the pool.

Hope this helps

Oleg 




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to