fix: preserve code agent short connection proxy headers

This commit is contained in:
Codex
2026-05-25 05:38:51 +00:00
parent 8f4be2e126
commit 76e8d90374
4 changed files with 39 additions and 2 deletions
@@ -4,9 +4,33 @@ import test from "node:test";
import {
isCloudWebSseRoute,
proxyCloudApiRequest
proxyCloudApiRequest,
upstreamRequestHeaders
} from "./cloud-web-proxy.mjs";
test("cloud web proxy preserves Code Agent short-connection headers", () => {
const headers = upstreamRequestHeaders({
headers: {
accept: "application/json",
"content-type": "application/json",
prefer: "respond-async",
"x-hwlab-short-connection": "1",
"x-trace-id": "trc_proxy_short_connection",
"x-request-id": "req_proxy_short_connection",
authorization: "Bearer must-not-forward"
}
}, "{\"message\":\"hello\"}");
assert.equal(headers.accept, "application/json");
assert.equal(headers["content-type"], "application/json");
assert.equal(headers.prefer, "respond-async");
assert.equal(headers["x-hwlab-short-connection"], "1");
assert.equal(headers["x-trace-id"], "trc_proxy_short_connection");
assert.equal(headers["x-request-id"], "req_proxy_short_connection");
assert.equal(headers.authorization, undefined);
assert.equal(headers["content-length"], Buffer.byteLength("{\"message\":\"hello\"}"));
});
test("cloud web proxy streams SSE chunks without fixed content-length", async () => {
const upstream = createServer((request, response) => {
assert.equal(request.headers["x-trace-id"], "trc_stream_proxy");