# HG changeset patch # User Sebastien Jodogne # Date 1506343813 -7200 # Node ID 26a0cc24d48d8e2eb676131b47cb390958ff05d6 # Parent 5edec967055e6f5530df5a9ca25e85c65205c89e New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip diff -r 5edec967055e -r 26a0cc24d48d NEWS --- 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) diff -r 5edec967055e -r 26a0cc24d48d OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- 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 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); Register("/instances/{id}/frames/{frame}/image-int16", GetImage); Register("/instances/{id}/frames/{frame}/matlab", GetMatlabImage); - Register("/instances/{id}/frames/{frame}/raw", GetRawFrame); + Register("/instances/{id}/frames/{frame}/raw", GetRawFrame); + Register("/instances/{id}/frames/{frame}/raw.gz", GetRawFrame); Register("/instances/{id}/pdf", ExtractPdf); Register("/instances/{id}/preview", GetImage); Register("/instances/{id}/image-uint8", GetImage);