comparison OrthancFramework/Sources/SystemToolbox.cpp @ 5407:3206537cbb56

HttpCompression: now disabled by default + only compress known compressible content types
author Alain Mazy <am@osimis.io>
date Sat, 04 Nov 2023 14:46:38 +0100
parents 303e930fff0f
children 59e3b6f8c5be
comparison
equal deleted inserted replaced
5405:62bb63346185 5407:3206537cbb56
723 { 723 {
724 return threads; 724 return threads;
725 } 725 }
726 } 726 }
727 727
728 bool SystemToolbox::IsContentCompressible(MimeType mime)
729 {
730 switch (mime)
731 {
732 case MimeType_Css:
733 case MimeType_Html:
734 case MimeType_JavaScript:
735 case MimeType_Json:
736 case MimeType_Pam:
737 case MimeType_Pdf:
738 case MimeType_PlainText:
739 case MimeType_WebAssembly:
740 case MimeType_Xml:
741 case MimeType_PrometheusText:
742 case MimeType_DicomWebJson:
743 case MimeType_DicomWebXml:
744 return true;
745 default: // for all other (JPEG, DICOM, binary, ...)
746 return false;
747 }
748 }
749
750 bool SystemToolbox::IsContentCompressible(const std::string& contentType)
751 {
752 if (contentType.empty())
753 {
754 return false;
755 }
756
757 if (contentType.find(MIME_JSON) != std::string::npos ||
758 contentType.find(MIME_XML) != std::string::npos ||
759 contentType.find(MIME_DICOM_WEB_JSON) != std::string::npos ||
760 contentType.find(MIME_DICOM_WEB_XML) != std::string::npos ||
761 contentType.find(MIME_PDF) != std::string::npos ||
762 contentType.find(MIME_CSS) != std::string::npos ||
763 contentType.find(MIME_HTML) != std::string::npos ||
764 contentType.find(MIME_JAVASCRIPT) != std::string::npos ||
765 contentType.find(MIME_PLAIN_TEXT) != std::string::npos ||
766 contentType.find(MIME_WEB_ASSEMBLY) != std::string::npos ||
767 contentType.find(MIME_XML_2) != std::string::npos)
768 {
769 return true;
770 }
771
772 return false;
773 }
728 774
729 MimeType SystemToolbox::AutodetectMimeType(const std::string& path) 775 MimeType SystemToolbox::AutodetectMimeType(const std::string& path)
730 { 776 {
731 std::string extension = boost::filesystem::extension(path); 777 std::string extension = boost::filesystem::extension(path);
732 Toolbox::ToLowerCase(extension); 778 Toolbox::ToLowerCase(extension);