No, you also have to set a CookieStore in the HttpContext. The attributes in the HttpContext you pass as a parameter take precedence over the default ones so using an empty HttpContext does not help. Some details here: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/statemgmt.html#d5e818
Anyway, in your case the most efficient solution is to tell HttpClient to ignore cookies instead of creating a HttpContext that will never be reused: httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); 2013/3/15 Albek, Elli (contractor) <[email protected]> > Thanks, > > To add, the code that use the client (called concurrently by many > threads): > > HttpResponse response = client.execute(call); > > HttpEntity entity = response.getEntity(); > if (entity != null) { > String body = EntityUtils.toString(entity); > String mime = entity.getContentType().getValue(); > // process response ... > } > > If we use new client.execute(call, new BasicHttpContext()) instead, > ^^^^^^^^^^^^^^^^^^^^ > > is that going to create a transient storage for cookies that will not be > used between calls? > > E > > > > -----Original Message----- > Francois-Xavier Bonnet > Sent: Thursday, March 14, 2013 9:55 PM > To: HttpComponents Project > Subject: Re: Exception parsing cookies > > I guess the application you are calling is developed with Zend framework > and the framework is setting automatically this cookie. I don't know if > there is a way to remove it. > > An HttpClient instance has a default CookieStore. If you don't set a > different HttpContext for each request with a CookieStore in it, > HttpClient > will use the same default CookieStore for all users. I think your > problem > comes from concurrent accesses to this CookieStore which is not thread > safe. > > If you want to be stateless, I suggest that you set HttpClient to just > ignore all cookies, this should solve your problem: > httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, > CookiePolicy.IGNORE_COOKIES); > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
