MediaTypeHeaderValue constructor throws if given a media type with params
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
_From @SteveSandersonMS on Thursday, March 30, 2017 5:15:43 AM_
Currently, `new MediaTypeHeaderValue("application/vnd.entity; v=2")` throws, giving the error *The format of value 'application/vnd.entity; v=2' is invalid*. Is this by design? It seems like it should be valid for an incoming `Content-Type` header to specify params.
Extra strange: `MediaTypeHeaderValue.TryParse("application/vnd.entity; v=2", out _)` returns `true`, implying that the same string is valid.
(Somewhat related to #718, in that it's also about extending the range of media types we parse)
_Copied from original issue: aspnet/HttpAbstractions#805_
Contributor guide
Research direction
Start by comparing the MediaTypeHeaderValue constructor with MediaTypeHeaderValue.TryParse using the reported value "application/vnd.entity; v=2". Trace the existing validation and parsing behavior, then add focused coverage showing whether both entry points should accept the same media type with parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100