fix: remove duplicate pipeline when serving bundle

Related: https://github.com/socketio/socket.io/issues/4946
This commit is contained in:
Damien Arrachequesne
2024-02-12 18:05:04 +01:00
parent e36062ca2d
commit e426f3e8e1
2 changed files with 15 additions and 1 deletions

View File

@@ -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":

View File

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