From 58eeb53d88d149336e5382f164378fbdd3270d44 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Tue, 4 Aug 2026 14:46:09 -0300 Subject: [PATCH] feat(api): add response content encoding verification (#6736) --- .../6736-response-content-encoding.md | 1 + .../compression-header-verification.test.ts | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 changelog.d/features/6736-response-content-encoding.md create mode 100644 tests/unit/compression-header-verification.test.ts diff --git a/changelog.d/features/6736-response-content-encoding.md b/changelog.d/features/6736-response-content-encoding.md new file mode 100644 index 0000000000..14ed572868 --- /dev/null +++ b/changelog.d/features/6736-response-content-encoding.md @@ -0,0 +1 @@ +- **feat(api):** add response content encoding verification — confirms Next.js compress:true and documents stripStaleForwardingHeaders behavior ([#6736](https://github.com/diegosouzapw/OmniRoute/issues/6736)) diff --git a/tests/unit/compression-header-verification.test.ts b/tests/unit/compression-header-verification.test.ts new file mode 100644 index 0000000000..6679b68956 --- /dev/null +++ b/tests/unit/compression-header-verification.test.ts @@ -0,0 +1,36 @@ +import { describe, it } from "node:test"; +import { ok, equal } from "node:assert/strict"; + +describe("Response compression verification (#6736)", () => { + it("next.config.mjs has compress: true", async () => { + // Read the config file and verify compression is enabled + const fs = await import("fs"); + const content = fs.readFileSync("next.config.mjs", "utf-8"); + ok(content.includes("compress: true"), "Next.js compression should be enabled"); + }); + + it("stripStaleForwardingHeaders deletes content-encoding", async () => { + const { stripStaleForwardingHeaders } = await import( + "@/../open-sse/handlers/chatCore/responseHeaders" + ); + const headers = new Headers({ "content-encoding": "gzip", "x-custom": "keep" }); + stripStaleForwardingHeaders(headers); + equal(headers.has("content-encoding"), false, "content-encoding should be stripped"); + ok(headers.has("x-custom"), "custom headers should survive"); + }); + + it("stripStaleForwardingHeaders deletes content-length and transfer-encoding", async () => { + const { stripStaleForwardingHeaders } = await import( + "@/../open-sse/handlers/chatCore/responseHeaders" + ); + const headers = new Headers({ + "content-length": "1024", + "content-encoding": "gzip", + "transfer-encoding": "chunked", + }); + stripStaleForwardingHeaders(headers); + equal(headers.has("content-length"), false); + equal(headers.has("content-encoding"), false); + equal(headers.has("transfer-encoding"), false); + }); +});