# HG changeset patch # User Sebastien Jodogne # Date 1560008821 -7200 # Node ID 0222a9afa866b11f01c8c77ddf5f030abf11461f # Parent 05b4f440a96192f0e3496324bd92387840970606 reorganization diff -r 05b4f440a961 -r 0222a9afa866 Plugin/Configuration.cpp --- a/Plugin/Configuration.cpp Sat Jun 08 17:42:49 2019 +0200 +++ b/Plugin/Configuration.cpp Sat Jun 08 17:47:01 2019 +0200 @@ -536,5 +536,61 @@ { return defaultEncoding_; } + + + static bool IsXmlExpected(const std::string& acceptHeader) + { + std::string accept; + Orthanc::Toolbox::ToLowerCase(accept, acceptHeader); + + if (accept == "application/dicom+json" || + accept == "application/json" || + accept == "*/*") + { + return false; + } + else if (accept == "application/dicom+xml" || + accept == "application/xml" || + accept == "text/xml") + { + return true; + } + else + { + OrthancPlugins::LogError("Unsupported return MIME type: " + accept + + ", will return DICOM+JSON"); + return false; + } + } + + + bool IsXmlExpected(const std::map& headers) + { + std::map::const_iterator found = headers.find("accept"); + + if (found == headers.end()) + { + return false; // By default, return DICOM+JSON + } + else + { + return IsXmlExpected(found->second); + } + } + + + bool IsXmlExpected(const OrthancPluginHttpRequest* request) + { + std::string accept; + + if (OrthancPlugins::LookupHttpHeader(accept, request, "accept")) + { + return IsXmlExpected(accept); + } + else + { + return false; // By default, return DICOM+JSON + } + } } } diff -r 05b4f440a961 -r 0222a9afa866 Plugin/Configuration.h --- a/Plugin/Configuration.h Sat Jun 08 17:42:49 2019 +0200 +++ b/Plugin/Configuration.h Sat Jun 08 17:47:01 2019 +0200 @@ -101,5 +101,10 @@ const std::string& sopInstanceUid); Orthanc::Encoding GetDefaultEncoding(); + + bool IsXmlExpected(const std::map& headers); + + // TODO => REMOVE + bool IsXmlExpected(const OrthancPluginHttpRequest* request); } } diff -r 05b4f440a961 -r 0222a9afa866 Plugin/QidoRs.cpp --- a/Plugin/QidoRs.cpp Sat Jun 08 17:42:49 2019 +0200 +++ b/Plugin/QidoRs.cpp Sat Jun 08 17:47:01 2019 +0200 @@ -494,7 +494,8 @@ std::string wadoBase = OrthancPlugins::Configuration::GetBaseUrl(request); - OrthancPlugins::DicomWebFormatter::HttpWriter writer(output, IsXmlExpected(request)); + OrthancPlugins::DicomWebFormatter::HttpWriter writer( + output, OrthancPlugins::Configuration::IsXmlExpected(request)); // Fix of issue #13 for (ResourcesAndInstances::const_iterator diff -r 05b4f440a961 -r 0222a9afa866 Plugin/StowRs.cpp --- a/Plugin/StowRs.cpp Sat Jun 08 17:42:49 2019 +0200 +++ b/Plugin/StowRs.cpp Sat Jun 08 17:47:01 2019 +0200 @@ -28,63 +28,6 @@ #include -static bool IsXmlExpected(const std::string& acceptHeader) -{ - std::string accept; - Orthanc::Toolbox::ToLowerCase(accept, acceptHeader); - - if (accept == "application/dicom+json" || - accept == "application/json" || - accept == "*/*") - { - return false; - } - else if (accept == "application/dicom+xml" || - accept == "application/xml" || - accept == "text/xml") - { - return true; - } - else - { - OrthancPlugins::LogError("Unsupported return MIME type: " + accept + - ", will return DICOM+JSON"); - return false; - } -} - - -bool IsXmlExpected(const std::map& headers) -{ - std::map::const_iterator found = headers.find("accept"); - - if (found == headers.end()) - { - return false; // By default, return DICOM+JSON - } - else - { - return IsXmlExpected(found->second); - } -} - - - // TODO => REMOVE -bool IsXmlExpected(const OrthancPluginHttpRequest* request) -{ - std::string accept; - - if (OrthancPlugins::LookupHttpHeader(accept, request, "accept")) - { - return IsXmlExpected(accept); - } - else - { - return false; // By default, return DICOM+JSON - } -} - - void StowCallback(OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request) @@ -259,7 +202,7 @@ result[OrthancPlugins::DICOM_TAG_FAILED_SOP_SEQUENCE.Format()] = failed; result[OrthancPlugins::DICOM_TAG_REFERENCED_SOP_SEQUENCE.Format()] = success; - const bool isXml = IsXmlExpected(request); + const bool isXml = OrthancPlugins::Configuration::IsXmlExpected(request); std::string answer; { @@ -465,6 +408,6 @@ "The STOW-RS plugin currently only supports \"application/dicom\" subtype"); } - return new Handler(context, IsXmlExpected(headers), wadoBase, expectedStudy); + return new Handler(context, Configuration::IsXmlExpected(headers), wadoBase, expectedStudy); } } diff -r 05b4f440a961 -r 0222a9afa866 Plugin/StowRs.h --- a/Plugin/StowRs.h Sat Jun 08 17:42:49 2019 +0200 +++ b/Plugin/StowRs.h Sat Jun 08 17:47:01 2019 +0200 @@ -26,10 +26,6 @@ #include -bool IsXmlExpected(const std::map& headers); - -bool IsXmlExpected(const OrthancPluginHttpRequest* request); - void StowCallback(OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request);