For 1.2 RC3 I modified the update check so that it first retrieves the last modified date of the project feed (HTTP HEAD method), if the date is newer than the last check than it will download the feed. This should reduce the amount of traffic on our website. [skip ci]

This commit is contained in:
RKrom 2014-11-14 10:45:45 +01:00
parent 380f581bbe
commit c6d6431a81
5 changed files with 51 additions and 2 deletions

View file

@ -336,6 +336,27 @@ namespace GreenshotPlugin.Core {
return responseData;
}
/// <summary>
/// Get LastModified for a URI
/// </summary>
/// <param name="uri">Uri</param>
/// <returns>DateTime</returns>
public static DateTime GetLastModified(Uri uri) {
HttpWebRequest webRequest;
try {
webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(uri);
webRequest.Method = "HEAD";
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
LOG.DebugFormat("RSS feed was updated at {0}", webResponse.LastModified);
return webResponse.LastModified;
} catch (Exception wE) {
LOG.WarnFormat("Problem requesting HTTP - HEAD on uri {0}", uri);
LOG.Warn(wE.Message);
// Pretend it is old
return DateTime.MinValue;
}
}
}
/// <summary>