Hi Dave,

Take a look at this thread -
http://old.nabble.com/Best-Practices-for-Multithreaded-use-of-HttpClient-(with-Cookies)--td27345690.html
- I think that may help.

I think, in your case, you're going to need to grab a new HttpClient
instance from the ThreadSafeClientConnectionManager if you want truly
unique cookie stores for the same target host:port. We have a similar
use case, and have gone down this route.

Thanks,

Sam


On 17 February 2010 18:51, Dave Irving <dave.irv...@bankofamerica.com> wrote:
>
> Hi,
>
> I'm using HttpClient (4) to talk to some web services. I'd like lots of
> requests to be sent in parallel, so I'm using
> ThreadSafeClientConnectionManager along with a high per-host total
> connection thresholds.
>
> All requests thru this client will be to the same host / port (and most of
> the time to the same URL).
> So the result (without playing with anything) is that cookies get shared
> across all connections.
>
> The quick question is:
>
> - Is there any way to tie cookies to the _connection_ that they originated
> in (and not be shared outside this). I.e. supplying a HttpContext from the
> "outside" wont work here. Transparent to the caller, I just want cookies to
> only be used on the connection they originated on.
>
>
> If you're wondering 'why' - the longer question is:
>
> The server is doing NTLM (spring security) and uses an HttpSession to manage
> the state of the authentication process. So, we get a session id sent back
> as a cookie. Thats the only cookie ever needed, and ever cared about.
> However, if we have N connections, they all end up sharing the sessionid
> cookie - and obviously things blow up (out of step authentication sequences
> etc).
> I dont want to have to supply an HttpContext from the "outside" (caller), as
> there isn't (and shouldn't be) any way to tell one call apart from another.
> (All connections will be authenticated with the same credentials - its just
> that each connection needs to be authenticated exactly once.)
>
> If I could somehow make cookies only apply (be scoped to) a _connection_
> this would all work like a treat.
>
> (NTLM is the real problem here I think, but unfortunately no way out of
> that... For now)
> --
> View this message in context: 
> http://old.nabble.com/Using-HttpClient-%284%29-with-%27per-connection%27-state-tp27628555p27628555.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to