You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2009/12/03 10:16:20 UTC

[jira] Resolved: (HTTPCLIENT-896) CLONE -Parsing expires

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-896?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCLIENT-896.
------------------------------------------

    Resolution: Won't Fix

The format of the cookie in question is compatible with the Netscape Draft specification only. The best match cookie policy correctly identifies the cookie as Netscape but parsing of the 'expires' attribute fails because the only date format permitted by the Netscape Draft is "EEE, dd MMM-yyyy-HH:mm:ss z". In order to make HttpClient accept cookies containing nonstandard 'expires' one should set valid date formats using 'http.protocol.cookie-datepatterns' parameter. See example:

-----
BasicHttpParams params = new BasicHttpParams();
params.setParameter(CookieSpecPNames.DATE_PATTERNS, 
        Arrays.asList("EEE, dd MMM-yyyy-HH:mm:ss z", "EEE, dd MMM yyyy HH:mm:ss z"));
BestMatchSpecFactory factory = new BestMatchSpecFactory();
CookieSpec cookiespec = factory.newInstance(params);
BasicHeader header = new BasicHeader("Set-Cookie", 
        "asid=011e7014f5e7718e02d893335aa5a16e; path=/; " +
        "expires=Wed, 16 May 2018 17:13:32 GMT");
CookieOrigin origin = new CookieOrigin("localhost", 80, "/", false);
List<Cookie> cookies = cookiespec.parse(header, origin);
System.out.println(cookies);
-----

I guess the policy was made stricter sometime post 4.0-beta1

Hope this clarifies the situation somewhat

Oleg

> CLONE -Parsing expires
> ----------------------
>
>                 Key: HTTPCLIENT-896
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-896
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>            Reporter: Fuad Efendi
>
> Seeing this very often:
>  Invalid cookie header: "Set-Cookie: _asid=011e7014f5e7718e02d893335aa5a16e; path=/; expires=Wed, 16 May 2018 17:13:32 GMT". Unable to parse expires attribute: Wed, 16 May 2018 17:13:32 GMT

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org