hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Krugler <kkrugler_li...@transpac.com>
Subject Setting cookie policy with HttpClient 4.0
Date Fri, 07 Aug 2009 17:32:32 GMT
Hi all,

I'm seeing errors in my logs relating to parsing the expires date  
value in a cookie:

09/08/07 10:26:46 WARN protocol.ResponseProcessCookies:137 - Invalid  
cookie header: "Set-Cookie: IU=deleted; expires=Thu, 07 Aug 2008  
17:26:45 GMT; path=/; domain=.yahoo.com". Unable to parse expires  
attribute: Thu, 07 Aug 2008 17:26:45 GMT

I looked through the HtttpClient source, and it seems like if I've set  
up my cookie policy properly, the above date would be parsed properly.

Here's now I'm setting up the cookie policy:

HttpParams params = new BasicHttpParams();
CookieSpecParamBean cookieParams = new CookieSpecParamBean(params);
ClientConnectionManager cm = new ThreadSafeClientConnManager(params,  
DefaultHttpClient httpClient = new DefaultHttpClient(cm, params);
params = httpClient.getParams();
HttpClientParams.setCookiePolicy(params, CookiePolicy.BEST_MATCH);

But the above code was assembled from a few different snippets online,  
IIRC. So maybe this isn't correct.

For example, in the "Choosing Cookie Policy" section of the tutorial  
docs, it uses the setParameter() API to set the policy:


I assume the two are equivalent, but any input would be appreciated.


-- Ken

+1 530-265-2225

Ken Krugler
TransPac Software, Inc.
+1 530-210-6378

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message