Fixes #5061: create generic method to check http status

Again, please use HTTP vocabulary here and clarify as follows:

> Performing a HTTP ${method} request on ${url}, expecting a response with status code ${expected_status}

I think we should not include the ${headers} in the log as they may contain sensitive authentication information.