Skip to content

Commit

Permalink
fix: response content-type is not XML of uploading XML
Browse files Browse the repository at this point in the history
# Problems
- When using `application/fhir+xml;charset=UTF-8` as accept,
it does not set to "application/fhir+xml"

# Solutions
- Change the condition to check if accept includes a list of XML
  • Loading branch information
Chinlinlee committed Oct 8, 2023
1 parent 16e090f commit fe1982d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ module.exports = function (app) {
"xml"
];

if (xmlAcceptList.includes(req.headers.accept)) {
res.set("Content-Type", "application/fhir+xml");
} else {
res.set("Content-Type", "application/fhir+json");
for(let i = 0 ; i< xmlAcceptList.length ; i++) {
let xmlAccept = xmlAcceptList[i];
if (req.headers.accept.includes(xmlAccept)) {
res.set("Content-Type", "application/fhir+xml");
} else {
res.set("Content-Type", "application/fhir+json");
}
}

setFormatWhenQuery(req, res);
doPrettyJson(app, req);
next();
Expand Down

0 comments on commit fe1982d

Please sign in to comment.