# HG changeset patch # User Sebastien Jodogne # Date 1578488496 -3600 # Node ID 7a0460c5e98e4a7903d6180e6315c5777e7932ca # Parent 227ebd71802fcd3c98769557794470025c1e04bd don't follow redirections if contacting the Orthanc REST API diff -r 227ebd71802f -r 7a0460c5e98e Framework/Loaders/GenericLoadersContext.h --- 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 -#include - #include namespace OrthancStone diff -r 227ebd71802f -r 7a0460c5e98e Framework/Loaders/SeriesThumbnailsLoader.cpp --- 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(message.GetOrigin()); assert(command.HasPayload()); - dynamic_cast(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(command.GetPayload()); + AcquireThumbnail(info.GetDicomSource(), info.GetStudyInstanceUid(), + info.GetSeriesInstanceUid(), new Thumbnail(SeriesThumbnailType_Unsupported)); + } + else + { + dynamic_cast(command.GetPayload()).HandleError(); + } } @@ -490,7 +502,7 @@ if (found == thumbnails_.end()) { - return SeriesThumbnailType_Unknown; + return SeriesThumbnailType_NotLoaded; } else { diff -r 227ebd71802f -r 7a0460c5e98e Framework/Loaders/SeriesThumbnailsLoader.h --- 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 }; diff -r 227ebd71802f -r 7a0460c5e98e Framework/Oracle/GenericOracleRunner.cpp --- 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());