perf(transport): 全链路传输压缩优化

- 上游请求启用 HTTP/2 (HPACK 头部压缩 + 多路复用),添加 h2 依赖
- 上游请求体超过阈值时自动 gzip 压缩,使用紧凑 JSON 序列化
- 添加 brotli 依赖,Accept-Encoding 支持 gzip/deflate/br
- 隧道帧压缩: Rust 端响应帧和 Python 端请求/响应帧均支持 gzip
- Rust 端压缩/解压逻辑统一提取到 protocol.rs
- Rust 端请求头构建改用 .headers() 替换 reqwest 默认值
- 新增 ENABLE_HTTP2、ENABLE_REQUEST_COMPRESSION 等环境变量配置
This commit is contained in:
fawney19
2026-02-28 21:02:21 +08:00
parent 3ff67fec2f
commit a2d1cff3b0
10 changed files with 279 additions and 59 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ dependencies = [
"pydantic>=2.12.5",
"python-dotenv>=1.2.1",
"openai>=2.16.0",
"httpx[socks]>=0.28.1",
"httpx[socks,http2]>=0.28.1",
"brotli>=1.1.0",
"sqlalchemy>=2.0.46",
"alembic>=1.18.3",
"bcrypt>=5.0.0",