Skip to content

Commit c7e53dd

Browse files
[FIX] set a default behavior for http methods
Before this commit. there was no default behavior in case the method request was not handled, which meant that we would try to iterate on an undefined `registeredRoutes` which would lead to a traceback. The issue is not critical as it only leads to an `ERROR` in the logs.
1 parent 3184fb1 commit c7e53dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/services/http.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ class RouteListener {
181181
case "POST":
182182
registeredRoutes = this.POSTs.entries();
183183
break;
184+
default:
185+
logger.warn(`[${remoteAddress}] ${req.method} is not allowed on ${req.url}`);
186+
res.statusCode = 405; // Method not allowed
187+
return res.end();
184188
}
185189
for (const [pattern, options] of registeredRoutes) {
186190
if (pathname === pattern) {

0 commit comments

Comments
 (0)