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, {