Mercurial > hg > orthanc-stone
changeset 1254:7a0460c5e98e broker
don't follow redirections if contacting the Orthanc REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 Jan 2020 14:01:36 +0100 |
parents | 227ebd71802f |
children | c1c83c1fb837 |
files | Framework/Loaders/GenericLoadersContext.h Framework/Loaders/SeriesThumbnailsLoader.cpp Framework/Loaders/SeriesThumbnailsLoader.h Framework/Oracle/GenericOracleRunner.cpp |
diffstat | 4 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Loaders/GenericLoadersContext.h Wed Jan 08 10:35:39 2020 +0100 +++ b/Framework/Loaders/GenericLoadersContext.h Wed Jan 08 14:01:36 2020 +0100 @@ -23,13 +23,10 @@ #include "../Messages/IMessageEmitter.h" #include "../Oracle/ThreadedOracle.h" +#include "ILoadersContext.h" #include "DicomSource.h" -#include "ILoaderFactory.h" #include "OracleScheduler.h" -#include <Core/HttpClient.h> -#include <Core/Toolbox.h> - #include <boost/thread/recursive_mutex.hpp> namespace OrthancStone
--- a/Framework/Loaders/SeriesThumbnailsLoader.cpp Wed Jan 08 10:35:39 2020 +0100 +++ b/Framework/Loaders/SeriesThumbnailsLoader.cpp Wed Jan 08 14:01:36 2020 +0100 @@ -47,7 +47,7 @@ } else { - return SeriesThumbnailType_Unknown; + return SeriesThumbnailType_Unsupported; } } @@ -185,7 +185,7 @@ } else { - SeriesThumbnailType type = SeriesThumbnailType_Unknown; + SeriesThumbnailType type = SeriesThumbnailType_Unsupported; std::string sopClassUid; if (value.size() > 0 && @@ -429,7 +429,19 @@ { const OracleCommandBase& command = dynamic_cast<const OracleCommandBase&>(message.GetOrigin()); assert(command.HasPayload()); - dynamic_cast<Handler&>(command.GetPayload()).HandleError(); + + if (command.GetType() == IOracleCommand::Type_GetOrthancImage) + { + // This is presumably a HTTP status 301 (Moved permanently) + // because of an unsupported DICOM file in "/preview" + const ThumbnailInformation& info = dynamic_cast<const ThumbnailInformation&>(command.GetPayload()); + AcquireThumbnail(info.GetDicomSource(), info.GetStudyInstanceUid(), + info.GetSeriesInstanceUid(), new Thumbnail(SeriesThumbnailType_Unsupported)); + } + else + { + dynamic_cast<Handler&>(command.GetPayload()).HandleError(); + } } @@ -490,7 +502,7 @@ if (found == thumbnails_.end()) { - return SeriesThumbnailType_Unknown; + return SeriesThumbnailType_NotLoaded; } else {
--- a/Framework/Loaders/SeriesThumbnailsLoader.h Wed Jan 08 10:35:39 2020 +0100 +++ b/Framework/Loaders/SeriesThumbnailsLoader.h Wed Jan 08 14:01:36 2020 +0100 @@ -34,10 +34,11 @@ { enum SeriesThumbnailType { - SeriesThumbnailType_Unknown = 1, - SeriesThumbnailType_Pdf = 2, - SeriesThumbnailType_Video = 3, - SeriesThumbnailType_Image = 4 + SeriesThumbnailType_NotLoaded = 1, // The remote server cannot decode this image + SeriesThumbnailType_Unsupported = 2, // The remote server cannot decode this image + SeriesThumbnailType_Pdf = 3, + SeriesThumbnailType_Video = 4, + SeriesThumbnailType_Image = 5 };
--- a/Framework/Oracle/GenericOracleRunner.cpp Wed Jan 08 10:35:39 2020 +0100 +++ b/Framework/Oracle/GenericOracleRunner.cpp Wed Jan 08 14:01:36 2020 +0100 @@ -152,6 +152,7 @@ const OrthancRestApiCommand& command) { Orthanc::HttpClient client(orthanc, command.GetUri()); + client.SetRedirectionFollowed(false); client.SetMethod(command.GetMethod()); client.SetTimeout(command.GetTimeout()); @@ -188,6 +189,7 @@ const GetOrthancImageCommand& command) { Orthanc::HttpClient client(orthanc, command.GetUri()); + client.SetRedirectionFollowed(false); client.SetTimeout(command.GetTimeout()); CopyHttpHeaders(client, command.GetHttpHeaders()); @@ -208,6 +210,7 @@ const GetOrthancWebViewerJpegCommand& command) { Orthanc::HttpClient client(orthanc, command.GetUri()); + client.SetRedirectionFollowed(false); client.SetTimeout(command.GetTimeout()); CopyHttpHeaders(client, command.GetHttpHeaders());