#1068 Cookie handling broken - only sends one cookie

Dare Obasanjo
Dare Obasanjo

Hi team,

Something about the cookie handler isn't working right. RSS Bandit only sends the first cookie name/value pair for a domain when requesting a feed update.

ex: IE sends this cookie when requesting a page on my domain:
a=1; b=2; c=3; test=a

RSS bandit sends this cookie:

Suggestions? Looking in CurrentWork\Source\NewsComponents\Net\AsyncWebRequest.cs(1403), clearly there's a bug in there somewhere. I'll be happy to try to fix it rather than wait for the next release. :)

Does this project build with VC# 2005? On import it said the project was built with a prior version.

Change this function AsyncWebRequest.cs:GetCookieContainerUri to this:

    private static CookieContainer GetCookieContainerUri(Uri url) {
        CookieContainer container = new CookieContainer();
        string cookieHeaders = RetrieveIECookiesForUrl(url.AbsoluteUri);
        if (cookieHeaders.Length > 0) {
                // This doesn't work for ';' separated cookies!!!
        //container.SetCookies(url, cookieHeaders);
                // example: a=2; b=3; c=4; d=5; e=YES
                string cookieHeaders2 = cookieHeaders.Replace(';', ',');
                container.SetCookies(url, cookieHeaders2);
            }catch(System.Net.CookieException ce){ //we might get an error on malformed cookies
                _log.Error("GetCookieContainerUri() caused exception", ce);
        return container;

The blind swap of a semicolon in the raw cookie string to the expected comma separator of the CookieContainer set method may cause other problems if your cookies expect to store semicolons. Though it works for my purposes.


  • Logged In: YES
    Originator: NO

    We also get exceptions on Vista/CLR 2.0 like this:
    System.Net.CookieException: An error occurred when parsing the Cookie header for Uri 'http://weblogs.asp.net/favicon.ico'. ---> System.Net.CookieException: Cookie format error.
    at System.Net.CookieContainer.CookieCutter(Uri uri, String headerName, String setCookieHeader, Boolean isThrow)
    --- End of inner exception stack trace ---
    at System.Net.CookieContainer.CookieCutter(Uri uri, String headerName, String setCookieHeader, Boolean isThrow)
    at System.Net.CookieContainer.SetCookies(Uri uri, String cookieHeader)
    at NewsComponents.Net.HttpCookieManager.GetCookieContainerUri(Uri url)

  • James Harrell
    James Harrell

    Logged In: YES
    Originator: NO

    I reported this bug and provided the code to fix it quite a while back. Can you implement this code in the next release?