comparison OrthancServer/Sources/ServerContext.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 566e8d32bd3a
children
comparison
equal deleted inserted replaced
5405:62bb63346185 5406:aaf7c49a9ddc
896 { 896 {
897 throw OrthancException(ErrorCode_UnknownResource); 897 throw OrthancException(ErrorCode_UnknownResource);
898 } 898 }
899 else 899 else
900 { 900 {
901 ContentCompression contentCompression = ContentCompression_Unknown;
902
903 // try to avoid compressing a large DICOM file ( > 1MB) that is already compressed (For large files, this could take multiple seconds)
904 std::string transferSyntaxString;
905 DicomTransferSyntax transferSyntax;
906 int64_t revision;
907
908 if (content == FileContentType_Dicom &&
909 attachment.GetUncompressedSize() > 1*1024*1024 && // don't even waste time reading the TransferSyntax from DB for "small" DICOM files
910 index_.LookupMetadata(transferSyntaxString, revision, resourceId, ResourceType_Instance, MetadataType_Instance_TransferSyntax) &&
911 LookupTransferSyntax(transferSyntax, transferSyntaxString))
912 {
913 contentCompression = (IsCompressedTransferSyntax(transferSyntax) ? ContentCompression_AlreadyCompressed : ContentCompression_NotCompressed);
914 }
915
901 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); 916 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
902 accessor.AnswerFile(output, attachment, GetFileContentMime(content)); 917 accessor.AnswerFile(output, attachment, GetFileContentMime(content), contentCompression);
903 } 918 }
904 } 919 }
905 920
906 921
907 void ServerContext::ChangeAttachmentCompression(const std::string& resourceId, 922 void ServerContext::ChangeAttachmentCompression(const std::string& resourceId,