mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Codex CLI 0.125+ defaults to sending request bodies with Content-Encoding: zstd. Without server-side decompression the gateway returns 'Failed to parse request body' on /v1/responses (and any other JSON endpoint) because gjson sees raw zstd bytes. ReadRequestBodyWithPrealloc now inspects Content-Encoding and transparently decodes zstd, gzip/x-gzip, and deflate bodies before returning them, then strips the encoding headers and updates ContentLength so downstream code can reuse the bytes safely. Unsupported encodings produce a clear error. Adds unit tests covering identity, zstd, gzip, deflate, unsupported encoding, corrupt zstd payloads, nil bodies, and explicit identity.