remotebackend http: move iterator loops into a helper func

As discussed on IRC.

Please note that this is compile-tested only.

Also this exposes that calculateSOASerial never does anything with the post data ;-)