Ignore Header parameters so that charset=utf-8 will not fail to match on a valid Formatter #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The existing behavior can be seen by running the Hl7.DemoFileSystemFhirServer.AspNetCore project as is. Requesting a fhir resource with an "Accept" header of "application/json+fhir; charset=utf-8" I would expect the results to be json but they are returned as xml. But, because the base type of TextInputFormatter matches on the header parameters also we do not find a matching formatter and return the first one registered.
This PR overrides CanWriteResult to ignore the header parameter. This results in the Json Formatter being selected for output formatting. It may be appropriate to check encoding if it exists and ensure it is not something other than utf-8. Also this code would allow a path forward for other misc header parameters like fhirVersion.