I used your example URL and read the contents via:
var dataStream = response.GetResponseStream();
var reader = new StreamReader(dataStream);
var responseFromServer = reader.ReadToEnd();
The result I get is:
20/feb/2018: Hi! We seem to be receiving high volume requests coming from empty user agents. While this shouldn't be an issue, this unfortunately resulted in bandwidth issues on this server causing all downloads to be unavailable. We've therefore decided to temporarily block empty user agents until we upgraded our server bandwidth.
03/mar/2018: We've upgraded the server bandwidth. This is however still not sufficient to handle all empty user agent connections. Please update the user agent in your scripts accordingly or contact us so we can discuss it.
Thank you for your understanding.
It says that set UserAgent
. So, I set the user agent as follows:
var request = HttpWebRequest.CreateHttp(url);
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1";
var response = (HttpWebResponse)(await request.GetResponseAsync());
var length = response.ContentLength;
Now, I get the correct Content-Length
value of 25691309
I just picked an user agent string from:
http://www.useragentstring.com/index.php?id=19879
If you just interested in the size of the remote file, you should consider the answer to the linked question. It essentially uses a different HTTP Metho (HEAD vs GET)
var request = HttpWebRequest.CreateHttp(url);
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1";
request.Method = "HEAD";
using (var response = await request.GetResponseAsync())
{
var length = response.ContentLength;
}
You are find more details about HEAD Vs GET in the related question:
http HEAD vs GET performance