Added bound to number of HTTP redirects, and prevented redirect loops.