fix: parse Accept header media type to allow parameters like charset=utf-8 - #5740
Conversation
…utf-8 The $export endpoint rejected Accept headers containing media type parameters such as 'application/fhir+json; charset=utf-8', which .NET HttpClient appends automatically. Changed exact string comparison to MediaTypeHeaderValue.TryParse so only the media type is compared, ignoring any additional parameters. Fixes microsoft#3876
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
MadhukarJukanti please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
MadhukarJukanti please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Fixes #3876
Description
---Problem
The $export endpoint validates the Accept header using exact string comparison against application/fhir+json.
When .NET's HttpClient makes the request, it automatically appends ; charset=utf-8, producing
application/fhir+json; charset=utf-8 — which the exact match rejects with a 400 error.
Fix
Replaced string.Equals with MediaTypeHeaderValue.TryParse so only the media type portion is compared, ignoring
any additional parameters such as charset.
Tests Added
Three new test cases in ValidateExportRequestFilterAttributeTests:
All three now pass without throwing RequestNotValidException.
Related issues
Addresses [issue #].
Testing
Describe how this change was tested.
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)