From 911d0e35757ea9ee93d1807c401c734661615e96 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 1 May 2023 07:24:27 +0200 Subject: [PATCH] refactor: return HTTP 400 upon invalid request overlap In both cases, the error comes from the client as it should not send multiple concurrent requests, so a HTTP 4xx code is mandated. Related: https://github.com/socketio/engine.io/issues/650 --- lib/transports/polling.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/transports/polling.ts b/lib/transports/polling.ts index 69a968eb..70be3411 100644 --- a/lib/transports/polling.ts +++ b/lib/transports/polling.ts @@ -75,8 +75,7 @@ export class Polling extends Transport { debug("request overlap"); // assert: this.res, '.req and .res should be (un)set together' this.onError("overlap from client"); - // TODO for the next major release: use an HTTP 400 status code (https://github.com/socketio/engine.io/issues/650) - res.writeHead(500); + res.writeHead(400); res.end(); return; } @@ -117,8 +116,7 @@ export class Polling extends Transport { if (this.dataReq) { // assert: this.dataRes, '.dataReq and .dataRes should be (un)set together' this.onError("data request overlap from client"); - // TODO for the next major release: use an HTTP 400 status code (https://github.com/socketio/engine.io/issues/650) - res.writeHead(500); + res.writeHead(400); res.end(); return; }