dispose res properly

This commit is contained in:
Matthias Mailänder
2015-08-29 18:46:58 +02:00
parent 589cb4cd0a
commit 72dffe3391

View File

@@ -210,12 +210,13 @@ namespace OpenRA
// Request the filename from the server
// Run in a worker thread to avoid network delays
var mapUrl = Game.Settings.Game.MapRepository + Uid;
var mapPath = string.Empty;
try
{
var request = WebRequest.Create(mapUrl);
request.Method = "HEAD";
var res = request.GetResponse();
using (var res = request.GetResponse())
{
// Map not found
if (res.Headers["Content-Disposition"] == null)
{
@@ -223,7 +224,8 @@ namespace OpenRA
return;
}
var mapPath = Path.Combine(baseMapPath, res.Headers["Content-Disposition"].Replace("attachment; filename = ", ""));
mapPath = Path.Combine(baseMapPath, res.Headers["Content-Disposition"].Replace("attachment; filename = ", ""));
}
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i => { DownloadBytes = i.BytesReceived; DownloadPercentage = i.ProgressPercentage; };
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>