(PDB-663) Restore curl_with_retries with some improvements

Signed-off-by: Ken Barber <ken@bob.sh>