feat(api): add response content encoding verification (#6736)

This commit is contained in:
diegosouzapw
2026-08-04 14:46:09 -03:00
parent 7163081f5e
commit 58eeb53d88
2 changed files with 37 additions and 0 deletions

View File

@@ -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))

View File

@@ -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);
});
});