If a request includes a cookie with whitespace in it's name, GetCookies will return 0 cookies.
The attached fiddler sessions demonstrate the issue. Below is the implementation of the method that was called.
In the initial request the cookie header is:
Cookie: c1=v1; c2=v2; c3=v3;
This returns a count of 3
In the second request the cookie header is:
Cookie: c1=v1; c2=v2; c3=v3; bad cookie=trouble;
This returns a count of 0
[HttpGet]
public HttpResponseMessage CountCookies()
{
return Request.CreateResponse(HttpStatusCode.OK, new {CookieCount = Request.Headers.GetCookies().Sum(x => x.Cookies.Count)});
}
The attached fiddler sessions demonstrate the issue. Below is the implementation of the method that was called.
In the initial request the cookie header is:
Cookie: c1=v1; c2=v2; c3=v3;
This returns a count of 3
In the second request the cookie header is:
Cookie: c1=v1; c2=v2; c3=v3; bad cookie=trouble;
This returns a count of 0
[HttpGet]
public HttpResponseMessage CountCookies()
{
return Request.CreateResponse(HttpStatusCode.OK, new {CookieCount = Request.Headers.GetCookies().Sum(x => x.Cookies.Count)});
}