Skip to content
New issue

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

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

Already on GitHub? # to your account

Charset in accept makes the server ignore the entire media-type requested #4676

Open
csteeg opened this issue Oct 14, 2024 · 4 comments
Open
Labels
Up for grabs The issue require minimal context and is well-suited for new contributors.

Comments

@csteeg
Copy link

csteeg commented Oct 14, 2024

Describe the bug
When sending the charset alongside the media-type in the accept-header, the entire header is ignored.
If sending "Accept: application/fhir+xml;charset=UTF-8" I get a json response.
Sending "Accept: application/fhir+xml" or "Accept: application/fhir+xml;q=0.8" I correctly get xml.

According to the standard https://www.[iana.org/assignments/media-types/application/fhir+xml](https://www.iana.org/assignments/media-types/application/fhir+xml) it's an accepted parameter for this media-type

FHIR Version?
Stu3/R4/R5 -> all

Data provider?
CosmosDB/SQL Server -> both

To Reproduce
Steps to reproduce the behavior:

  1. Send a request with the header "Accept: application/fhir+xml;charset=UTF-8"

Expected behavior
An xml result

Actual behavior
JSON result

@csteeg csteeg added the Bug Bug bug bug. label Oct 14, 2024
@EXPEkesheth
Copy link
Contributor

Thanks for reporting the issue!

Are you using the OSS FHIR service or managed FHIR service? Marking it for "UpforGrabs"

@EXPEkesheth EXPEkesheth added Up for grabs The issue require minimal context and is well-suited for new contributors. and removed Bug Bug bug bug. labels Oct 14, 2024
@csteeg
Copy link
Author

csteeg commented Oct 15, 2024

We're using the OSS self hosted version

@EXPEkesheth
Copy link
Contributor

@csteeg - Thanks for the response! The Azure FHIR service supports JSON by default. Currently, XML support is only available as an open-source capability, which makes it a lower priority for our queue at this time.

@csteeg
Copy link
Author

csteeg commented Dec 9, 2024

This seems to be a problem of .net MVC framework?
If I add
SupportedMediaTypes.Add($"{KnownContentTypes.XmlContentType}; charset=utf-8");
SupportedMediaTypes.Add($"{KnownContentTypes.XmlContentType}; charset=utf-16");
to the FhirXmlOutputFormatter constructor, it works.

The CanWriteResult of the base OutputFormatter, calls parsedContentType.IsSubsetOf(supportedMediaType) which in the end calls private bool ContainsAllParameters(MediaTypeParameterParser setParameters) in ReadOnlyMediaTypeHeaderValue

I don't know exactly if IsSubsetOf is really supposed to match the Charset also, but if so the supportedmediatypes should be added for all currently supported mediatypes I guess

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Up for grabs The issue require minimal context and is well-suited for new contributors.
Projects
None yet
Development

No branches or pull requests

2 participants