Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CookieParser bug: _index, _cookieValue and _cookieName not reset in Parse(...) #32

Open
henon opened this issue Aug 6, 2016 · 1 comment

Comments

@henon
Copy link

henon commented Aug 6, 2016

_index, _cookieValue and _cookieName have to be set to 0, "" and "" respectively at the start of Parse(...) method or only the first cookie parsing will yield correct result.

@henon
Copy link
Author

henon commented Oct 5, 2016

Here is the fix for that issue in HttpCookieParser change the Parse method to

    /// <summary>
    /// Parse cookie string
    /// </summary>
    /// <returns>A generated cookie collection.</returns>
    public IHttpCookieCollection<IHttpCookie> Parse(string value)
    {
        _index = 0;
        _cookieValue = "";
        _cookieName = "";
        if (value == null) throw new ArgumentNullException("value");
        _headerValue = value;
        _cookies = new HttpCookieCollection<IHttpCookie>();
        _parserMethod = Name_Before;

        while (!IsEOF)
        {
            _parserMethod();
        }

        OnCookie(_cookieName, _cookieValue);
        return _cookies;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant