TheKitsuneWithATie TheKitsuneWithATie - 8 months ago 29
HTTP Question

Which HTTP response code to send on unhandled request

I have a PHP application that has a router that should have two default handlers for

401 Unauthorized
404 Not Found

But it could happen that no handlers were set for those two cases. In that case, I need to have a default response that tells
Request Unhandled
, I have set it to the response code
400 Bad Request
, but I feel like its not truly appropriate.

What response code should I use for a unhandled request?


4xx is generally a client's problem. 5xx is your (server-side) problem. So if you cannot handle a request - it is HTTP 5xx.

In this case it looks that 501 Not Implemented is the best fit.