Fixes #5061: create generic method to check http status