Fixes #5061: create generic method to check http status

You have used a "s" at the end of each of these variables (codes), which indicates to me that this may be multivalued.

This makes sense as a possibility, but my understanding would be that in this case, these variables are passed as a slist (or ilist, actually). If that is the case, then this will try and iterate over each line, therefore trying to redefine kept_returncodes as many times as there are values in the list (or at least I assume it will).

I think this should either be limited to one return code, or adapted to use a slist ("@{kept_return_codes}", etc), or at the very least commented to explain what format and argument types are expected.