From a95c1c5b7ac1bb872f33c102124f25ff232e9947 Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Tue, 11 Feb 2014 17:27:50 -0800 Subject: [PATCH] Added initial HEAD request when downloading updates to determine download size. --- AboutPage.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/AboutPage.cs b/AboutPage.cs index 58d610968..927bf8747 100644 --- a/AboutPage.cs +++ b/AboutPage.cs @@ -227,6 +227,22 @@ namespace MatterHackers.MatterControl string downloadUri = string.Format("https://mattercontrol.appspot.com/downloads/development/{0}", ApplicationSettings.Instance.get("CurrentBuildToken")); string downloadToken = ApplicationSettings.Instance.get("CurrentBuildToken"); + //Make HEAD request to determine the size of the download (required by GAE) + System.Net.WebRequest request = System.Net.WebRequest.Create(downloadUri); + request.Method = "HEAD"; + + int downloadSize; + try + { + WebResponse response = request.GetResponse(); + downloadSize = (int)response.ContentLength; + } + catch + { + //Unknown download size + downloadSize = 0; + } + if (!System.IO.Directory.Exists(updateFileLocation)) { System.IO.Directory.CreateDirectory(updateFileLocation);