Fixes #5061: create generic method to check http status

Please clarify:

> Expected status code of the HTTP response