-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should return 405 (Method Not Allowed) for invalid request methods #3238
Comments
Oh, actually... with a server const http = require('http');
http.createServer((req, res) =>
{
res.statusCode = 501;
res.end();
})
.listen(8888); I observed:
I don't understand why 405 or 501 cannot be returned?
|
RFC compliance (it's a SHOULD so more like accommodation than compliance) in this case is not worth the cost. Checking for a matching route across all existing methods, just to return a slightly more accurate but really utterly useless information is not reasonable. If you care so much about this, you can manually add every possible verb to every path you configure with a 405 or 501 response. You can't do a catch all because that should remain a 404. |
I see that the method lookup is the shorter path in the implementation: https://github.com/hapijs/call/blob/260bb6c1fb447f27b5f53a2a7ebd46120c4271e7/lib/index.js#L108 Thanks for the response and an explanation. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
According to RFC:
With a server
I expected
$ curl http://localhost:8888/
to result in405 Method Not Allowed
.I observed:
Unlike #3127, it is possible to return
405 Method Not Allowed
from node.js:With a server
I observed:
The text was updated successfully, but these errors were encountered: