Specify caching policy for XML/MSI downloads

Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
Danilo Del Busso 2023-04-13 11:44:23 +01:00
parent bfd99e1869
commit 44d4482513
No known key found for this signature in database
2 changed files with 5 additions and 0 deletions

View File

@ -33,6 +33,7 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Cache;
using System.Net.NetworkInformation;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
@ -84,6 +85,7 @@ namespace XenAdmin.Actions.Updates
_client = new WebClient();
_client.DownloadProgressChanged += client_DownloadProgressChanged;
_client.DownloadFileCompleted += client_DownloadFileCompleted;
_client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
// register event handler to detect changes in network connectivity
NetworkChange.NetworkAvailabilityChanged += NetworkAvailabilityChanged;

View File

@ -36,6 +36,7 @@ using System.Xml;
using XenAdmin.Core;
using System.Diagnostics;
using System.Net;
using System.Net.Cache;
namespace XenAdmin.Actions
@ -356,6 +357,8 @@ namespace XenAdmin.Actions
using (var webClient = new WebClient())
{
webClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
webClient.Proxy = proxy;
webClient.Headers.Add("User-Agent", _userAgent);
using (var stream = new MemoryStream(webClient.DownloadData(uriBuilder.Uri)))