From e426f3e8e1bfea5720c32d30a3663303200ee6ad Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 12 Feb 2024 18:05:04 +0100 Subject: [PATCH] fix: remove duplicate pipeline when serving bundle Related: https://github.com/socketio/socket.io/issues/4946 --- lib/index.ts | 1 - test/server-attachment.ts | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index 48497e3352..bd77218318 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -625,7 +625,6 @@ export class Server< switch (encoding) { case "br": res.writeHead(200, { "content-encoding": "br" }); - readStream.pipe(createBrotliCompress()).pipe(res); pipeline(readStream, createBrotliCompress(), res, onError); break; case "gzip": diff --git a/test/server-attachment.ts b/test/server-attachment.ts index 98d005a3d9..81da1acbcd 100644 --- a/test/server-attachment.ts +++ b/test/server-attachment.ts @@ -70,6 +70,21 @@ describe("server attachment", () => { }); }); + it("should serve client (br)", (done) => { + const srv = createServer(); + new Server(srv); + request(srv) + .get("/socket.io/socket.io.js") + .set("accept-encoding", "br") + .buffer(true) + .end((err, res) => { + if (err) return done(err); + expect(res.headers["content-encoding"]).to.be("br"); + expect(res.status).to.be(200); + done(); + }); + }); + it("should serve client with necessary CORS headers", (done) => { const srv = createServer(); new Server(srv, {