# HG changeset patch # User Alain Mazy # Date 1636447874 -3600 # Node ID 0a38000b086de6349047c6b1fa05ae3ba71eda3a # Parent ae643f66462821c43e9ee62953bcfac95e90704e Archive jobs response now contains a header Content-Disposition:filename='archive.zip' diff -r ae643f664628 -r 0a38000b086d NEWS --- a/NEWS Thu Oct 28 13:05:56 2021 +0200 +++ b/NEWS Tue Nov 09 09:51:14 2021 +0100 @@ -10,9 +10,10 @@ -------- * API version upgraded to 16 -* If an image can not be decoced, ../preview and ../rendered routes are now returning +* If an image can not be decoded, ../preview and ../rendered routes are now returning unsupported.png only if the ?returnUnsupportedImage option is specified; otherwise, it raises a 415 error code. +* Archive jobs response now contains a header Content-Disposition:filename='archive.zip' diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/IJob.h --- a/OrthancFramework/Sources/JobsEngine/IJob.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/IJob.h Tue Nov 09 09:51:14 2021 +0100 @@ -59,6 +59,7 @@ // "success" state virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) = 0; }; } diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp --- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -650,6 +650,7 @@ bool JobsRegistry::GetJobOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& job, const std::string& key) { @@ -668,7 +669,7 @@ if (handler.GetState() == JobState_Success) { - return handler.GetJob().GetOutput(output, mime, key); + return handler.GetJob().GetOutput(output, mime, filename, key); } else { diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/JobsRegistry.h --- a/OrthancFramework/Sources/JobsEngine/JobsRegistry.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/JobsRegistry.h Tue Nov 09 09:51:14 2021 +0100 @@ -148,6 +148,7 @@ bool GetJobOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& job, const std::string& key); diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp --- a/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -448,6 +448,7 @@ bool SequenceOfOperationsJob::GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) { return false; diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h --- a/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/Operations/SequenceOfOperationsJob.h Tue Nov 09 09:51:14 2021 +0100 @@ -125,6 +125,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE; void AwakeTrailingSleep(); diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp --- a/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -270,6 +270,7 @@ bool SetOfCommandsJob::GetOutput(std::string &output, MimeType &mime, + std::string& filename, const std::string &key) { return false; diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h --- a/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/JobsEngine/SetOfCommandsJob.h Tue Nov 09 09:51:14 2021 +0100 @@ -104,6 +104,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE; }; } diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/RestApi/RestApiOutput.cpp --- a/OrthancFramework/Sources/RestApi/RestApiOutput.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/RestApi/RestApiOutput.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -214,4 +214,9 @@ // empty string SetCookie(name, "", 1); } + + void RestApiOutput::SetContentFilename(const char* filename) + { + output_.SetContentFilename(filename); + } } diff -r ae643f664628 -r 0a38000b086d OrthancFramework/Sources/RestApi/RestApiOutput.h --- a/OrthancFramework/Sources/RestApi/RestApiOutput.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/Sources/RestApi/RestApiOutput.h Tue Nov 09 09:51:14 2021 +0100 @@ -77,6 +77,8 @@ size_t length, MimeType contentType); + void SetContentFilename(const char* filename); + void SignalError(HttpStatus status); void SignalError(HttpStatus status, diff -r ae643f664628 -r 0a38000b086d OrthancFramework/UnitTestsSources/JobsTests.cpp --- a/OrthancFramework/UnitTestsSources/JobsTests.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -125,6 +125,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE { return false; diff -r ae643f664628 -r 0a38000b086d OrthancServer/Plugins/Engine/PluginsJob.h --- a/OrthancServer/Plugins/Engine/PluginsJob.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancServer/Plugins/Engine/PluginsJob.h Tue Nov 09 09:51:14 2021 +0100 @@ -75,6 +75,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE { // TODO diff -r ae643f664628 -r 0a38000b086d OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -696,10 +696,16 @@ std::string value; MimeType mime; + std::string filename; if (OrthancRestApi::GetContext(call).GetJobsEngine(). - GetRegistry().GetJobOutput(value, mime, job, key)) + GetRegistry().GetJobOutput(value, mime, filename, job, key)) { + if (!filename.empty()) + { + call.GetOutput().SetContentFilename(filename.c_str()); + } + call.GetOutput().AnswerBuffer(value, mime); } else diff -r ae643f664628 -r 0a38000b086d OrthancServer/Sources/ServerJobs/ArchiveJob.cpp --- a/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -1196,6 +1196,7 @@ bool ArchiveJob::GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) { if (key == "archive" && @@ -1208,6 +1209,7 @@ const DynamicTemporaryFile& f = dynamic_cast(accessor.GetItem()); f.GetFile().Read(output); mime = MimeType_Zip; + filename = "archive.zip"; return true; } else diff -r ae643f664628 -r 0a38000b086d OrthancServer/Sources/ServerJobs/ArchiveJob.h --- a/OrthancServer/Sources/ServerJobs/ArchiveJob.h Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.h Tue Nov 09 09:51:14 2021 +0100 @@ -118,6 +118,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE; }; } diff -r ae643f664628 -r 0a38000b086d OrthancServer/UnitTestsSources/ServerJobsTests.cpp --- a/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Thu Oct 28 13:05:56 2021 +0200 +++ b/OrthancServer/UnitTestsSources/ServerJobsTests.cpp Tue Nov 09 09:51:14 2021 +0100 @@ -140,6 +140,7 @@ virtual bool GetOutput(std::string& output, MimeType& mime, + std::string& filename, const std::string& key) ORTHANC_OVERRIDE { return false;