client: extract the get_chunk closure
This have no reason to be a closure, so we extract it as a proper function.