Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Multiple Accept headers are pulled out as 1 item causing Contains to fail #745

Closed
@jchannon

Description

@jchannon

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.

screen shot 2016-12-20 at 14 54 12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions