Fix marqdo-ext-http#13: `http.文本字节` allocated a fixed 8 MiB Memory region on
every call, and `http.构建请求字节` called it once for the request line and once
per header, so a 6-header request spent ~56 MiB of the default 64 MiB run
budget and a second request failed with `resource.exhausted`.
- `文本字节`: request the minimal page count for the actual text (4-byte
UTF-8 worst case per codepoint, 128-page cap, 1 page minimum).
- `构建请求字节`: concatenate the request line and all headers into one text,
encode once, then concatenate the body; per-header fixed allocations are gone.
- Public signatures and produced request bytes are unchanged (`构建请求` text
API stays compatible).
- Regression case: under the default budget, build the same 6-header request 8
times and assert the final byte length/request text; the old code failed on
the second build.
- docs/evidence records the real CLI/Bundle run.
No CLI/Host change, no new Host request, no release; real loopback multi-request
exchange (#3) and the optional streaming response view remain open/UNVERIFIED.
cflmy
merged commit 8fe0bee24c into main2026-11-30 12:29:02 +08:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
概述
修复
marqdo-ext-http#13:http.文本字节固定 8 MiB 分配 +构建请求字节每头一次分配,导致 6 头请求第二次即耗尽默认 64 MiB 预算(resource.exhausted)。不改公开签名/请求字节、不改 CLI/Host、不新增 Host 请求。修复
文本字节:按实际码点数申请最小页数(UTF-8 上界 4 字节/码点,128 页上限,1 页最小)。构建请求字节:请求行 + 全部头先拼成一个文本单次编码,再 concat 正文;去掉每头固定分配。字节文本原已按长度计算页数,不变;请求字节逐字节结果与文本 API 兼容。验证(真实,Linux x86_64 / glibc 2.43)
新增回归:默认内存预算下用 6 个头连续构造 8 次请求 → 成功;末次长度 169,末次请求文本符合 HTTP/1.1(逐字节断言在 case 中)。修复前第二次构造即触预算(问题单真实探针)。证据:
docs/evidence-2026-11-30-byte-budget.md。未验证:真实 127.0.0.1 loopback 多请求(#3)与可选的分块/大响应流式视图;未创建 release/tag。
refs #13 #11 #3