From fe1982dbe6ccdef5a322141965169209c786a38c Mon Sep 17 00:00:00 2001 From: chinlinlee Date: Sun, 8 Oct 2023 18:40:38 +0800 Subject: [PATCH] fix: response content-type is not XML of uploading XML # 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 --- routes.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes.js b/routes.js index d8c6e39d..f071c683 100644 --- a/routes.js +++ b/routes.js @@ -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();