Mercurial > hg > orthanc
diff OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 5406:aaf7c49a9ddc am-http-compression
tentative to implement smart HTTP compression with detection of transfer syntax
author | Alain Mazy <am@osimis.io> |
---|---|
date | Sat, 04 Nov 2023 13:42:30 +0100 |
parents | c5f1865aaa3b |
children |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Tue Oct 17 15:06:11 2023 +0200 +++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp Sat Nov 04 13:42:30 2023 +0100 @@ -360,14 +360,14 @@ { if (pixelItem->getLength() == 0) { - output.AnswerBuffer(NULL, 0, MimeType_Binary); + output.AnswerBuffer(NULL, 0, MimeType_Binary, ContentCompression_AlreadyCompressed); return true; } Uint8* buffer = NULL; if (pixelItem->getUint8Array(buffer).good() && buffer) { - output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary); + output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary, ContentCompression_AlreadyCompressed); return true; } } @@ -378,7 +378,7 @@ // This is the case for raw, uncompressed image buffers assert(*blockUri == "0"); DicomFieldStream stream(*element, transferSyntax); - output.AnswerStream(stream); + output.AnswerStream(stream, ContentCompression_NotCompressed); } } } @@ -838,7 +838,17 @@ std::string serialized; if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObjectConst().getDataset())) { - output.AnswerBuffer(serialized, MimeType_Dicom); + ContentCompression contentCompression = ContentCompression_Unknown; + DicomTransferSyntax transferSyntax; + + if (LookupTransferSyntax(transferSyntax)) + { + contentCompression = (IsCompressedTransferSyntax(transferSyntax) ? ContentCompression_AlreadyCompressed : ContentCompression_NotCompressed); + } + + output.AnswerBuffer(serialized, + MimeType_Dicom, + contentCompression); } } #endif