Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
([#8046](https://github.com/mitmproxy/mitmproxy/pull/8046), @HueCodes)
- Added support for adding and editing comments on individual flows in the mitmproxy console.
([#7944](https://github.com/mitmproxy/mitmproxy/pull/7944), @lups2000)
- Use stdlib (PEP-784) for Zstandard compression on Python 3.14+
([#8397](https://github.com/mitmproxy/mitmproxy/pull/8397), @Rogdham)

## 24 November 2025: mitmproxy 12.2.1

Expand Down
13 changes: 8 additions & 5 deletions mitmproxy/net/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
import codecs
import collections
import gzip
import sys
import zlib
from io import BytesIO
from typing import overload

import brotli
import zstandard as zstd

if sys.version_info >= (3, 14):
from compression import zstd
else: # pragma: no cover
from backports import zstd

# We have a shared single-element cache for encoding and decoding.
# This is quite useful in practice, e.g.
Expand Down Expand Up @@ -182,14 +187,12 @@ def encode_brotli(content: bytes) -> bytes:
def decode_zstd(content: bytes) -> bytes:
if not content:
return b""
zstd_ctx = zstd.ZstdDecompressor()
return zstd_ctx.stream_reader(BytesIO(content), read_across_frames=True).read()
return zstd.decompress(content)


def encode_zstd(content: bytes) -> bytes:
# Use level=1 for fastest compression speed.
zstd_ctx = zstd.ZstdCompressor(level=1)
return zstd_ctx.compress(content)
return zstd.compress(content, level=1)


def decode_deflate(content: bytes) -> bytes:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ requires-python = ">=3.12"
license = {file="LICENSE"}
authors = [{name = "Aldo Cortesi", email = "aldo@corte.si"}]
maintainers = [{name = "Maximilian Hils", email = "mitmproxy@maximilianhils.com"}]
version = "13.0.0-dev1+flare1"
version = "13.0.0-dev1+flare2"
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
Expand All @@ -33,6 +33,7 @@ dependencies = [
"aioquic>=1.2.0,<=1.2.0",
"argon2-cffi>=23.1.0,<=25.1.0",
"asgiref>=3.2.10,<=3.11.0",
"backports.zstd>=1.7.0,<=1.7.0 ; python_version<'3.14'",
"bcrypt>=5.0.0,<=5.0.0",
"Brotli>=1.0,<=1.2.1",
"certifi>=2019.9.11", # no upper bound here to get latest CA bundle
Expand All @@ -55,7 +56,6 @@ dependencies = [
"urwid>=2.6.14,<=3.0.3",
"wsproto>=1.0,<=1.3.2",
"publicsuffix2>=2.20190812,<=2.20191221",
"zstandard>=0.25",
]

[dependency-groups]
Expand Down
Loading
Loading