From 6c15dcb65f8435b863b5b914b4e163af43632a6a Mon Sep 17 00:00:00 2001 From: ExlauChen <285874446@qq.com> Date: Fri, 28 Mar 2025 14:50:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20can't=20establish=20sse?= =?UTF-8?q?=20when=20server=20side=20enable=20compress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/sse.test.ts | 10 +++++----- src/server/sse.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/sse.test.ts b/src/client/sse.test.ts index 2b166530..d2bf5911 100644 --- a/src/client/sse.test.ts +++ b/src/client/sse.test.ts @@ -24,7 +24,7 @@ describe("SSEClientTransport", () => { // Send SSE headers res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", }); @@ -183,7 +183,7 @@ describe("SSEClientTransport", () => { if (req.method === "GET") { res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", }); res.write("event: endpoint\n"); @@ -397,7 +397,7 @@ describe("SSEClientTransport", () => { res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", }); res.write("event: endpoint\n"); @@ -524,7 +524,7 @@ describe("SSEClientTransport", () => { if (auth === "Bearer new-token") { res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", }); res.write("event: endpoint\n"); @@ -610,7 +610,7 @@ describe("SSEClientTransport", () => { res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", }); res.write("event: endpoint\n"); diff --git a/src/server/sse.ts b/src/server/sse.ts index 84c1cbb9..e6cddc4e 100644 --- a/src/server/sse.ts +++ b/src/server/sse.ts @@ -44,7 +44,7 @@ export class SSEServerTransport implements Transport { this.res.writeHead(200, { "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", + "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", });