Unimplemented methods should return 405 status code #49

Open
rybesh opened this Issue Jan 26, 2012 · 6 comments

Projects

None yet

5 participants

@rybesh
rybesh commented Jan 26, 2012

Currently HTTP requests to a resource that specify a method unimplemented by that resource return a 404 Not Found status code. That is misleading, since the resource can be found—it just doesn't allow that method. It should return a 405 Method Not Allowed in this case.

This behavior (or at least the "Cannot [METHOD] [PATH]" message") seems to be coming from the connect lib; it's not clear to me whether it can or should be fixed there, or in express-resource.

@piotrek-r

Shouldn't this be 501? 4xx indicates client-side problems and not implementing a method is more like server-side thing to get done.

@rybesh
rybesh commented Mar 11, 2012

It's a client-side problem because the client has attempt to use a method unsupported by the resource. It's analogous to a 404 (where the client has requested a resource that doesn't exist).

@conradev

It's simple enough to implement:

var errorResponse = function(error) {
  return function(req, res) { res.send(error); };
}
app.delete('/notdeletable', errorResponse(405));

But I agree. The default error code for endpoints that exist but do not support the method should be 405

@hgwood
hgwood commented Nov 2, 2015

Any news on this?

@vendethiel

This project is long dead

@hgwood
hgwood commented Nov 3, 2015

My bad. PR for this feature in Express 4 is here: expressjs/express#2703.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment