On Fri, Aug 07, 2009 at 10:32:32AM -0700, Ken Krugler wrote:
> 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);
> cookieParams.setSingleHeader(true);
> ...
> ClientConnectionManager cm = new ThreadSafeClientConnManager(params,  
> schemeRegistry);
> 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.
>

Hi Ken

The code looks ok to me. In this particular case, though, you should simply be
using the 'http.protocol.cookie-datepatterns' parameter to override the default
expiry format.

http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/cookie/params/CookieSpecPNames.html#DATE_PATTERNS


> For example, in the "Choosing Cookie Policy" section of the tutorial  
> docs, it uses the setParameter() API to set the policy:
>
> httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY,  
> CookiePolicy.RFC_2965);
>
> I assume the two are equivalent, but any input would be appreciated.
>

Yes, they are.

Hope this helps

Oleg

> Thanks,
>
> -- Ken
>
> --------------------------------------------
> <http://ken-blog.krugler.org>
> +1 530-265-2225
>
>
>
>
> --------------------------
> Ken Krugler
> TransPac Software, Inc.
> <http://www.transpac.com>
> +1 530-210-6378
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to