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.
1.3 KiB
1.3 KiB
import
| import | ||
|---|---|---|
|
@exec http
main
响应文本 = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n6\r\n world\r\n0\r\n\r\n"
响应 = http.解析响应(响应文本)
请求 = http.构建请求("POST", "/echo", "Host", "example.test"], ["Content-Length", "2", "ok")
响应字节 = http.解析响应字节(http.文本字节("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n6\r\n你好\r\n0\r\n\r\n"))
正文 = http.字节文本(响应字节.value.body)
请求字节 = http.构建请求字节("POST", "/", [], [65, 66])
请求文本 = http.字节文本(请求字节)
次数 = 0
末长度 = 0
末文本 = ""
while 次数 < 8
请求字节 = http.构建请求字节("POST", "/v1/chat", 头列表, [123, 125])
末长度 = 长度(请求字节)
末文本 = http.字节文本(请求字节).value
次数 = 次数 + 1
end
return [响应.状态, 响应.原因, 响应.头["Content-Type"], 响应.体, 请求, 响应字节.value.status, 正文.value, 请求文本.value, 次数, 末长度, 末文本]