Exemple #1
0
 def post_build(self, pkt, pay):
     if not conf.contribs["http"]["auto_compression"]:
         return pkt + pay
     encodings = self._get_encodings()
     # Compress
     if "deflate" in encodings:
         import zlib
         pay = zlib.compress(pay)
     elif "gzip" in encodings:
         pay = gzip_compress(pay)
     elif "compress" in encodings:
         import lzw
         pay = lzw.compress(pay)
     elif "br" in encodings:
         if _is_brotli_available:
             pay = brotli.compress(pay)
         else:
             log_loading.info(
                 "Can't import brotli. brotli compression will "
                 "be ignored !")
     elif "zstd" in encodings:
         if _is_zstd_available:
             pay = zstandard.ZstdCompressor().compress(pay)
         else:
             log_loading.info(
                 "Can't import zstandard. zstd compression will "
                 "be ignored !")
     return pkt + pay
Exemple #2
0
 def post_build(self, pkt, pay):
     if not conf.contribs["http"]["auto_compression"]:
         return pkt + pay
     encodings = self._get_encodings()
     # Compress
     if "deflate" in encodings:
         import zlib
         pay = zlib.compress(pay)
     elif "gzip" in encodings:
         pay = gzip_compress(pay)
     elif "compress" in encodings:
         import lzw
         pay = lzw.compress(pay)
     return pkt + pay