added support for 307 redirects