implement checked curl downloading for known file types

This is to help us distinguish between truncated downloads (e.g. due to faulty proxies) and simply getting an error page. For example some of the downloads from sourceforge.net recently failed when SourceForge was in DR mode. Instead of getting "random" failure to gunzip zipped archives, or to install debian packages, instead let's see if the file appears to match what we would expect, if we recognize it. If not, fail with sensible error message.