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

  • 1
    404 is OK when you're deliberately accessing a page that doesn't exist. All of this is relative. – SomeKittens Feb 8 '13 at 2:08
  • Sounds like a very vague concept to me. How should you know when the site fails, more than the developers do? It's almost like you would need to say set up testing for all the different scenarios of the app, which sounds an awful lot like the automated testing the developers of the site should be doing. – sevenseacat Feb 8 '13 at 4:29
  • 1
    It would probably be safest to allow configuration of acceptable and unacceptable status codes by the user. – Carson63000 Feb 8 '13 at 5:54
  • 1
    Don't forget to handle 3xx. You need to follow the redirect(a limited number of times) before you get the real status code. Many HTTP libraries handle 3xx for you. – CodesInChaos Feb 8 '13 at 9:03
  • Thanks for all the comments and answer. @Carson63000 that was what I was gonna do after seeing this. Thanks. – wtsang02 Feb 8 '13 at 13:58

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
    (401 is the right response if you use http authentication since it requests different http credentials. If you other authentication (such as cookies+sessions) you'd use 403) – CodesInChaos Feb 8 '13 at 9:02

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
    Well, 200 may be acceptable or may indicate that something goes totally wrong. Example: a 200 instead of expected 301 indicates that the redirection system is down. A 200 instead of 401 is even worse, indicating that the security system is not working. – Arseni Mourzenko Feb 8 '13 at 2:57

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.