0

I have a test application that validates URLs to check if a particular service is up. Trouble is, I am validating a range of URLs which will send me a variety of Http Statuses, for eg:

200(OK) is valid and 302(Found) is also valid.

But 500 or 404 is not valid.

I'm not sure which Http Statuses indicate the service is up and running? Do we have a whitelist or any other reliable method to validate this?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mkl Rjv
  • 6,815
  • 5
  • 29
  • 47
  • If you're receiving HTTP status codes, then the service is up. For a certain value of up. At the very least, something is processing HTTP requests and producing responses. Whether it's working beyond that would be an application specific question. And, of course, mere milliseconds after you've received a response, the state of the service *may* be different to what the status code told you. – Damien_The_Unbeliever Nov 11 '16 at 07:28

1 Answers1

2

Even getting 200 does not mean that the server is doing what you want it to do really, since you can have a handler that masks all exception or what not. So it totally depends on what you want to verify. If you just want to check the server is responding, then all the statuses will do, since even 500 with the db exception means your server is running and responding to your requests.

Generally 4xx and 5xx are client and server error and you can use that. Just check wiki page. But if you want something more reasonable, you'll need to parse the responses to verify it contains something that you expect.

Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207