Parse Accept Header

2019-03-17 09:50发布

Does anyone have any suggestions (or a regular expression) for parsing the HTTP Accept header?

I am trying to do some content-type negotiation in ASP.NET MVC. There doesn't seem to be a built in way (which is fine, because there are a lot of schools of thought here), but the parsing is not entirely trivial and I would rather not re-invent the wheel if someone has already done it well and is willing to share.

7条回答
对你真心纯属浪费
2楼-- · 2019-03-17 10:29

I've written a parser in PHP. It's not complex, but it will give you an array of mime types in order of preference.

查看更多
登录 后发表回答