Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Header parameters so that charset=utf-8 will not fail to match on a valid Formatter #17

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

JoeShook
Copy link

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.

… on a valid Formatter

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.  This is because the base type of TextInputFormatter matches on the header parameters also.  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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants