# HG changeset patch # User Sebastien Jodogne # Date 1749657126 -7200 # Node ID 9fce9208f24f736483a8a3450ff0c907d4067e20 # Parent 86a076ceaf3a6dbe406b5d717088f3e1ec267acd# Parent 628edb487cec19649d45f9e8ebe53c131e5cada9 integration mainline->attach-custom-data diff -r 86a076ceaf3a -r 9fce9208f24f NEWS --- a/NEWS Wed Jun 11 16:55:15 2025 +0200 +++ b/NEWS Wed Jun 11 17:52:06 2025 +0200 @@ -34,6 +34,10 @@ In Orthanc 1.12.6 and 1.12.7, "RejectSopClasses" was used instead of the expected "RejectedSopClasses" spelling. * Fix the re-encoding of DICOM files larger than 4GB +* Improved translations of HTTP error codes when a plugin calls the core REST API. + e.g., a plugin could receive an error 17:OrthancPluginErrorCode_UnknownResource when the underlying + REST handler was actually returning an HTTP error 415. The plugin will now receive an + error 3000:OrthancPluginErrorCode_UnsupportedMediaType. REST API -------- diff -r 86a076ceaf3a -r 9fce9208f24f OrthancFramework/Sources/DicomFormat/DicomMap.cpp --- a/OrthancFramework/Sources/DicomFormat/DicomMap.cpp Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancFramework/Sources/DicomFormat/DicomMap.cpp Wed Jun 11 17:52:06 2025 +0200 @@ -43,6 +43,7 @@ #if !defined(__EMSCRIPTEN__) // Multithreading is not supported in WebAssembly # include +# include // For boost::unique_lock<> and boost::shared_lock<> #endif namespace Orthanc diff -r 86a076ceaf3a -r 9fce9208f24f OrthancFramework/Sources/HttpServer/IHttpHandler.cpp --- a/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancFramework/Sources/HttpServer/IHttpHandler.cpp Wed Jun 11 17:52:06 2025 +0200 @@ -51,7 +51,10 @@ if (handler.Handle(http, origin, LOCALHOST, "", HttpMethod_Get, curi, httpHeaders, getArguments, NULL /* no body for GET */, 0)) { - stream.GetBody(answerBody); + if (stream.GetStatus() == HttpStatus_200_Ok) + { + stream.GetBody(answerBody); + } if (answerHeaders != NULL) { diff -r 86a076ceaf3a -r 9fce9208f24f OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 11 17:52:06 2025 +0200 @@ -3362,6 +3362,10 @@ { throw OrthancException(ErrorCode_UnknownResource); } + else if (intHttpStatus == 415) + { + throw OrthancException(ErrorCode_UnsupportedMediaType); + } else { throw OrthancException(ErrorCode_BadRequest); diff -r 86a076ceaf3a -r 9fce9208f24f OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Wed Jun 11 17:52:06 2025 +0200 @@ -1566,7 +1566,7 @@ { if (!answer.IsEmpty()) { - result.assign(answer.GetData(), answer.GetSize()); + result.assign(reinterpret_cast(answer.GetData()), answer.GetSize()); } return true; } diff -r 86a076ceaf3a -r 9fce9208f24f OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Wed Jun 11 17:52:06 2025 +0200 @@ -235,11 +235,11 @@ OrthancPluginMemoryBuffer Release(); - const char* GetData() const + const void* GetData() const { if (buffer_.size > 0) { - return reinterpret_cast(buffer_.data); + return buffer_.data; } else { diff -r 86a076ceaf3a -r 9fce9208f24f OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp --- a/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp Wed Jun 11 16:55:15 2025 +0200 +++ b/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp Wed Jun 11 17:52:06 2025 +0200 @@ -221,7 +221,7 @@ OrthancPluginSetHttpHeader(OrthancPlugins::GetGlobalContext(), output, "Last-Modified", t.c_str()); - Answer(output, content.GetData(), content.GetSize(), mime); + Answer(output, reinterpret_cast(content.GetData()), content.GetSize(), mime); } } }