Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP response for unsupported HTTP methods with Node.js?

This is more specific to HTTP in general, but I'm using Node.js as my platform.

What is the best approach when dealing with non accepted HTTP methods to my HTTP server? Currently, I support PUT and GET, but not POST. If a POST request is made, should I return a 403, or a 405?

like image 430
wulfgarpro Avatar asked Dec 02 '12 02:12

wulfgarpro


2 Answers

If the HTTP method used is not acceptable, then according to the specification, you should return a 405 Method Not Allowed.

With 405, you must also include an Allow header specifying what HTTP methods are allowed. For example, Allow: POST, or if there are multiple choices, Allow: POST, PUT

like image 116
Jani Hartikainen Avatar answered Oct 04 '22 00:10

Jani Hartikainen


That would be "405 Method Not Allowed". Read all about it here: HTTP Status code definitions.

like image 24
Hubro Avatar answered Oct 03 '22 23:10

Hubro