fix(proxy/gateway): buffer non-streaming upstream bodies before replying
A non-streaming response is one JSON document, but the gateway was forwarding it chunk by chunk. When the upstream failed mid-body — HTTP/2 stream reset, GOAWAY, connection loss under concurrent subagent load — the client had already received a 200 header, so the failure surfaced as a truncated gzip payload and the ZlibError reported in #897 instead of an error the client could retry. Read the whole body before writing any header. On a read failure, retry the upstream once; if that also fails, return a clean 502 the client can act on. The 64MB buffer cap only bounds memory — a provider JSON document never approaches it — and streaming responses are untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
J
Julius Brussee committed
c27ea41a6ac6a78e7b555e4c09bd18b332a81f37
Parent: b8c1226