# HG changeset patch # User Alain Mazy # Date 1776169964 -7200 # Node ID adf75a7884fdbf68142fa9a57ffcef04b00c2466 # Parent 3962cdbde00b47df0dad37db011e9d4dc9692328 sync Orthanc + use framework 1.12.11 diff -r 3962cdbde00b -r adf75a7884fd CMakeLists.txt --- a/CMakeLists.txt Tue Apr 14 10:14:52 2026 +0200 +++ b/CMakeLists.txt Tue Apr 14 14:32:44 2026 +0200 @@ -26,7 +26,7 @@ set(ORTHANC_FRAMEWORK_VERSION "mainline") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") else() - set(ORTHANC_FRAMEWORK_VERSION "94c7f3784456") # while waiting for 1.12.11 (for SetCurrentThreadName fix) + set(ORTHANC_FRAMEWORK_VERSION "1.12.11") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") endif() diff -r 3962cdbde00b -r adf75a7884fd Resources/Orthanc/CMake/DownloadOrthancFramework.cmake --- a/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Tue Apr 14 10:14:52 2026 +0200 +++ b/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Tue Apr 14 14:32:44 2026 +0200 @@ -177,6 +177,8 @@ set(ORTHANC_FRAMEWORK_MD5 "66b5a2ee60706c4a502896083b9e1a01") elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.10") set(ORTHANC_FRAMEWORK_MD5 "d5e1ba442104c89a24013cb859a9d6bf") + elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.11") + set(ORTHANC_FRAMEWORK_MD5 "389b273b64b513ba8fc3233f34201cc1") # Below this point are development snapshots that were used to # release some plugin, before an official release of the Orthanc @@ -231,6 +233,11 @@ # for BlockingSharedMessageQueue.WaitEmpty() set(ORTHANC_FRAMEWORK_PRE_RELEASE ON) set(ORTHANC_FRAMEWORK_MD5 "c037cd2ddbe1b65b431692855483161b") + elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "56eb61c86f93") + # OE2 1.11.0 (framework post-1.12.10) + # for HttpClient that returns the answer body in case of HTTP error + set(ORTHANC_FRAMEWORK_PRE_RELEASE ON) + set(ORTHANC_FRAMEWORK_MD5 "665f8aa70d7c5091bc20da37cf664910") endif() endif() endif() diff -r 3962cdbde00b -r adf75a7884fd Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp --- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Tue Apr 14 10:14:52 2026 +0200 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Tue Apr 14 14:32:44 2026 +0200 @@ -1544,11 +1544,25 @@ #endif /* HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 */ + static void CheckAnswerSizeIsLessThan4GB(const std::string& answer) + { + if (answer.size() > static_cast(std::numeric_limits::max())) + { + #if HAS_ORTHANC_EXCEPTION == 1 + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "Cannot send HTTP response larger than 4GB"); + #else + ORTHANC_PLUGINS_LOG_ERROR("Cannot send HTTP response larger than 4GB"); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); + #endif + } + } + void AnswerJson(const Json::Value& value, OrthancPluginRestOutput* output) { std::string bodyString; - WriteStyledJson(bodyString, value); + WriteStyledJson(bodyString, value); + CheckAnswerSizeIsLessThan4GB(bodyString); OrthancPluginAnswerBuffer(GetGlobalContext(), output, bodyString.c_str(), bodyString.size(), "application/json"); } @@ -1556,6 +1570,7 @@ const char* mimeType, OrthancPluginRestOutput* output) { + CheckAnswerSizeIsLessThan4GB(answer); OrthancPluginAnswerBuffer(GetGlobalContext(), output, answer.c_str(), answer.size(), mimeType); } @@ -1564,6 +1579,26 @@ OrthancPluginSendHttpStatusCode(GetGlobalContext(), output, httpError); } + void AnswerHttpError(uint16_t httpError, + OrthancPluginRestOutput* output, + const std::string& answer, + const char* mimeType) + { + CheckAnswerSizeIsLessThan4GB(answer); + + OrthancPluginSetHttpHeader(GetGlobalContext(), + output, + "content-type", + mimeType); + + OrthancPluginSendHttpStatus(GetGlobalContext(), + output, + httpError, + answer.c_str(), + static_cast(answer.size())); + } + + void AnswerMethodNotAllowed(OrthancPluginRestOutput *output, const char* allowedMethods) { OrthancPluginSendMethodNotAllowed(GetGlobalContext(), output, allowedMethods); diff -r 3962cdbde00b -r adf75a7884fd Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h --- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Tue Apr 14 10:14:52 2026 +0200 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Tue Apr 14 14:32:44 2026 +0200 @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -690,6 +689,11 @@ void AnswerHttpError(uint16_t httpError, OrthancPluginRestOutput* output); + void AnswerHttpError(uint16_t httpError, + OrthancPluginRestOutput* output, + const std::string& answer, + const char* mimeType); + void AnswerMethodNotAllowed(OrthancPluginRestOutput* output, const char* allowedMethods); #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0) @@ -1025,7 +1029,20 @@ OrthancPluginSetMetricsValue(GetGlobalContext(), name, value, OrthancPluginMetricsType_Default); } +#endif + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 1) + inline void SetMetricsValue(const char* name, + int64_t value) + { + OrthancPluginSetMetricsIntegerValue(GetGlobalContext(), name, + value, OrthancPluginMetricsType_Default); + } +#endif + + +#if HAS_ORTHANC_PLUGIN_METRICS == 1 class MetricsTimer : public boost::noncopyable { private: