I am writing an application to report to the user(devs) when their website fails. And what I mean by fails which is unfunctional or needs to report the problem to devs.
I do understand that status code 2XX means ‘Success’ according to wiki. But does that really do? I have access my website once and returned 204 ‘No-Content’, which is unfunctional to me. So the question is, what are the list of status codes return should It be considered “website is functional”?
5
Every code is acceptable in some circumstances, but indicate a problem in other circumstances.
Take 404. It may indicate:
- that a link on your website is broken (which is actually a problem you may want to fix),
- that the client is trying deliberately to break the website (which is a problem too, but should be included in security reports instead),
- that somewhere, some website has a broken link or that a person misspelled an address (which doesn’t matter, since you can’t do anything with it),
- or that the page is not intended to exist (which is an expected situation and should not worry anybody). Example:
/wpad.dat
.
Take 200. It may indicate:
- a success,
- or that your security system is not working any longer, and is not forbidding the access to some very confidential web page to guests (the only acceptable response being
401 Unauthorized
).
If you want to report problems to developers, do it the right way: through logging and exception handling, not through something which was never intended for that, like HTTP status codes.
1
It depends on what exactly you are checking. Depending on what you check a 204 may be acceptable or it may be an error.
If you are checking a website, it is likely that 200 OK
is the only acceptable response. (After following redirects). If you are checking an API or something that isn’t intended to display in a browser, any 2xx
code may be acceptable.
1
The error codes which are meant to indicate that there is something wrong with the web service itself are the 5xx
errors. Those and only those. Returning anything else should indicate that the web service is working correctly. 4xx
errors are indication of error in the request, not on the server.