Handle http redirects and errors