Mercurial > hg > orthanc
changeset 2408:26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 25 Sep 2017 14:50:13 +0200 |
parents | 5edec967055e |
children | e4045b3c9772 |
files | NEWS OrthancServer/OrthancRestApi/OrthancRestResources.cpp |
diffstat | 2 files changed, 18 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Sep 20 17:02:27 2017 +0200 +++ b/NEWS Mon Sep 25 14:50:13 2017 +0200 @@ -2,6 +2,7 @@ =============================== * New security-related options: "DicomAlwaysAllowEcho" +* New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip * Use "GBK" (frequently used in China) as an alias for "GB18030" * Experimental support of actively maintained Civetweb to replace Mongoose 3.8 * Fix issue 64 (OpenBSD support)
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Wed Sep 20 17:02:27 2017 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Sep 25 14:50:13 2017 +0200 @@ -34,10 +34,11 @@ #include "../PrecompiledHeadersServer.h" #include "OrthancRestApi.h" +#include "../../Core/Compression/GzipCompressor.h" +#include "../../Core/DicomParsing/FromDcmtkBridge.h" +#include "../../Core/DicomParsing/Internals/DicomImageDecoder.h" #include "../../Core/HttpServer/HttpContentNegociation.h" #include "../../Core/Logging.h" -#include "../../Core/DicomParsing/FromDcmtkBridge.h" -#include "../../Core/DicomParsing/Internals/DicomImageDecoder.h" #include "../OrthancInitialization.h" #include "../Search/LookupResource.h" #include "../ServerContext.h" @@ -497,7 +498,7 @@ } - + template <bool GzipCompression> static void GetRawFrame(RestApiGetCall& call) { std::string frameId = call.GetUriComponent("frame", "0"); @@ -520,7 +521,17 @@ locker.GetDicom().GetRawFrame(raw, mime, frame); } - call.GetOutput().AnswerBuffer(raw, mime); + if (GzipCompression) + { + GzipCompressor gzip; + std::string compressed; + gzip.Compress(compressed, raw.empty() ? NULL : raw.c_str(), raw.size()); + call.GetOutput().AnswerBuffer(compressed, "application/gzip"); + } + else + { + call.GetOutput().AnswerBuffer(raw, mime); + } } @@ -1473,7 +1484,8 @@ Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>); Register("/instances/{id}/frames/{frame}/matlab", GetMatlabImage); - Register("/instances/{id}/frames/{frame}/raw", GetRawFrame); + Register("/instances/{id}/frames/{frame}/raw", GetRawFrame<false>); + Register("/instances/{id}/frames/{frame}/raw.gz", GetRawFrame<true>); Register("/instances/{id}/pdf", ExtractPdf); Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>);