(self, pkt, pay)
| 380 | return s |
| 381 | |
| 382 | def post_build(self, pkt, pay): |
| 383 | encodings = self._get_encodings() |
| 384 | if conf.contribs["http"]["auto_compression"]: |
| 385 | # Compress |
| 386 | if "deflate" in encodings: |
| 387 | import zlib |
| 388 | |
| 389 | pay = zlib.compress(pay) |
| 390 | elif "gzip" in encodings: |
| 391 | pay = gzip.compress(pay) |
| 392 | elif "compress" in encodings: |
| 393 | if _is_lzw_available: |
| 394 | pay = lzw.compress(pay) |
| 395 | else: |
| 396 | log_loading.info( |
| 397 | "Can't import lzw. compress compression " "will be ignored !" |
| 398 | ) |
| 399 | elif "br" in encodings: |
| 400 | if _is_brotli_available: |
| 401 | pay = brotli.compress(pay) |
| 402 | else: |
| 403 | log_loading.info( |
| 404 | "Can't import brotli. brotli compression will " "be ignored !" |
| 405 | ) |
| 406 | elif "zstd" in encodings: |
| 407 | if _is_zstd_available: |
| 408 | pay = zstandard.ZstdCompressor().compress(pay) |
| 409 | else: |
| 410 | log_loading.info( |
| 411 | "Can't import zstandard. zstd compression will " "be ignored !" |
| 412 | ) |
| 413 | # Chunkify |
| 414 | if conf.contribs["http"]["auto_chunk"] and "chunked" in encodings: |
| 415 | # Dumb: 1 single chunk. |
| 416 | pay = (b"%X" % len(pay)) + b"\r\n" + pay + b"\r\n0\r\n\r\n" |
| 417 | return pkt + pay |
| 418 | |
| 419 | def self_build(self, **kwargs): |
| 420 | """Takes an HTTPRequest or HTTPResponse object, and creates its |
nothing calls this directly
no test coverage detected