How to use HTTPClient to ensure cookies independently in the multi-threaded scen

HttpParams params =new BasicHttpParams();
ConnManagerParams.setTimeout(params, 45000);

HttpConnectionParams.setConnectionTimeout(params, 45000);

HttpConnectionParams.setSoTimeout(params, 45000);

// We set the HttpClient support HTTP and HTTPS two models
SchemeRegistry schReg =new SchemeRegistry();
schReg.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
schReg.register(new Scheme("https", SSLSocketFactory
.getSocketFactory(), 443));

// The use of thread safe connection management to create HttpClient
ClientConnectionManager conMgr =new ThreadSafeClientConnManager(
params, schReg);
client =new DefaultHttpClient(conMgr, params);

Although the above code can be used in multiple threads of the case, but cookies seems to be the only one, a client post has been cookies by a different thread client use
I would like to ask how to ensure cookies independently used in this case?

Started by Mavis at November 30, 2016 - 2:08 PM

In addition, the question now is
Request with a link, but need to request to a different session, the same httpclient that use ThreadSafeClientConnManager to access, seem to use the same cookie

It's like access to the CSDN forum at the same time, I hope that a client with Zhang San's account login, another client with Li Si's account, this how to get?

Posted by Mavis at December 01, 2016 - 2:20 PM

If you use the default DefaultHttpClient, as long as the new 2 don't seem to put cookies together, but DefaultHttpClient has no way to use in a multithreaded conditions

Posted by Mavis at December 10, 2016 - 3:18 PM