> I have a method that creates an instance of HttpClient and invokes an > execute method (an http post). I have two separate threads that invoke this > method. The method is totally thread-safe, i.e. each invocation of the > method will create its own instance of HttpClient. Will these two separate > HttpClient instances share state (like the underlying connection)? I am > finding that the second instance of HttpClient possesses the authenticated > cookie of the first instance, without authenticating.
Brad, You can make those separate HttpClient instances reference the same HttpState instance, which will effectively enable them to share HTTP state objects: cookies and credentials. However, it may be even a better idea to use the multithreaded connection manager and share the same HttpClient instance along with the HTTP state information it contains between multiple worker threads For more details refer to http://jakarta.apache.org/commons/httpclient/threading.html Cheers, Oleg -----Original Message----- From: Brad O'Hearne [mailto:[EMAIL PROTECTED] Sent: Monday, February 02, 2004 18:05 To: HttpClient Subject: Multiple instances of HttpClient sharing state? Hey gang, I have a method that creates an instance of HttpClient and invokes an execute method (an http post). I have two separate threads that invoke this method. The method is totally thread-safe, i.e. each invocation of the method will create its own instance of HttpClient. Will these two separate HttpClient instances share state (like the underlying connection)? I am finding that the second instance of HttpClient possesses the authenticated cookie of the first instance, without authenticating. Are instances of HttpClient sharing state, and if so, how do I keep different instances of HttpClient's state totally independent? BradO --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]