I am using System.Net.WebClient.DownloadFile to download a large number of html files from a public web server. I would like to enable compression because that could cut the data transfers by a large factor. I was told in a previous question that I should set the "Accept-Encoding: gzip, deflate" header. WebClient has a Headers property that would allow doing that.
I have a few questions about this:
- Assuming the web server recognizes the header, would this work with the DownloadFile method, or only with the DownloadData method? I couldn't find any information about this on MSDN or other sites.
- If it doesn't work with DownloadFile, what would be the simplest way of implementing downloading compressed data to a file?
- Does any other header need to be set for the server to compress its data? In an old codinghorror.com entry, Jeff Atwood said the "UserAgent" header also needs to be set, but I don't know what the value should be.