Mercurial > hg > orthanc-ohif
changeset 95:4e13ab335f8e
sync + use framework 1.12.10
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 17 Mar 2026 14:48:14 +0100 |
| parents | b82f12c20a5d |
| children | 04bd0a972a1d |
| files | CMakeLists.txt Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h |
| diffstat | 4 files changed, 54 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Tue Mar 17 09:48:00 2026 +0100 +++ b/CMakeLists.txt Tue Mar 17 14:48:14 2026 +0100 @@ -28,7 +28,7 @@ set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") else() - set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.12.5") + set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.12.10") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") endif()
--- a/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Tue Mar 17 09:48:00 2026 +0100 +++ b/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Tue Mar 17 14:48:14 2026 +0100 @@ -231,6 +231,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()
--- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Tue Mar 17 09:48:00 2026 +0100 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Tue Mar 17 14:48:14 2026 +0100 @@ -1544,11 +1544,25 @@ #endif /* HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 */ + static void CheckAnswerSizeIsLessThan4GB(const std::string& answer) + { + if (answer.size() > static_cast<size_t>(std::numeric_limits<uint32_t>::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<uint32_t>(answer.size())); + } + + void AnswerMethodNotAllowed(OrthancPluginRestOutput *output, const char* allowedMethods) { OrthancPluginSendMethodNotAllowed(GetGlobalContext(), output, allowedMethods);
--- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Tue Mar 17 09:48:00 2026 +0100 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Tue Mar 17 14:48:14 2026 +0100 @@ -690,6 +690,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) @@ -1026,6 +1031,13 @@ value, OrthancPluginMetricsType_Default); } + inline void SetMetricsValue(const char* name, + int64_t value) + { + OrthancPluginSetMetricsIntegerValue(GetGlobalContext(), name, + value, OrthancPluginMetricsType_Default); + } + class MetricsTimer : public boost::noncopyable { private:
