Handle redirects in downloads

Previously, the download behavior wrote the result of the first HTTP
call to the output location, regardless of the status code.  This
meant that in the case of 400s something useless was written.  In
addition (and the main trigger for this change) 300s would lead to
useless writes as well.  This change handles 300s by redirecting, and
200s by writing successfully.  All other status codes will result in a
failure of the application.