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

Add a copy constructor to MediaTypeHeaderValue #176

Closed
Tratcher opened this issue Jan 21, 2015 · 0 comments
Closed

Add a copy constructor to MediaTypeHeaderValue #176

Tratcher opened this issue Jan 21, 2015 · 0 comments

Comments

@Tratcher
Copy link
Member

Scenario:
MVC uses some lists of MTHVs to determine what formats are supported. They select one from the list and use it to configure the response. Sometimes this involves modifying the value (e.g. adding charset), however this affects the value in the list and may impact matching and output for subsequent requests.

To prevent modifications they need to make a copy of the MTHV. Right now they are using ToString and Parse to make a copy, which is least efficient way possible:
https://github.com/aspnet/Mvc/blob/eda4b16cc5dfc11528116c51e3a119c1b513e986/src/Microsoft.AspNet.Mvc.Core/Formatters/OutputFormatter.cs#L181

Add a copy constructor to avoid the all the string generation, string parsing, and parameter validation. NameValueHeaderValue will also require a copy constructor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants