mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
feat(api): add response content encoding verification (#6736)
This commit is contained in:
1
changelog.d/features/6736-response-content-encoding.md
Normal file
1
changelog.d/features/6736-response-content-encoding.md
Normal 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))
|
||||
36
tests/unit/compression-header-verification.test.ts
Normal file
36
tests/unit/compression-header-verification.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user