Multiple Accept headers are pulled out as 1 item causing Contains to fail #745
Description
When a client sends in multiple values in Accept
header doing a check on that header fails the Contains
method.
Looking at the Accept
header it is a StringValues
type which implements the many ICollection
,IList
,IEnumerable
etc interfaces and the value of the Accept
header is 1 entry with a string separated by comma. Therefore a IList.Contains
will fail because there isn't an entry that matches application/json
when the entry is application/json, text/plain, */*
I would have expected 3 entries in the result of calling context.Request.Headers["Accept"]
which would have made the check pass. For now I will have to use context.Request.Headers["Accept"].Any(h => h.Contains("application/json"))
or context.Request.Headers["Accept"].ToString().Contains("application/json"))
Attached is a screenshot of my debug window which shows what I saw.