Informancien
Informancien

Reputation: 255

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 and 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?

Upvotes: 1

Views: 1725

Answers (1)

zerkms
zerkms

Reputation: 254906

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.

References:

Upvotes: 5

Related Questions