diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 08c6b4e7fc..ae74819ecf 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -593,13 +593,14 @@ namespace OpenRA.Server { Task.Run(async () => { - var httpClient = HttpClientFactory.Create(); - var httpResponseMessage = await httpClient.GetAsync(playerDatabase.Profile + handshake.Fingerprint); - var result = await httpResponseMessage.Content.ReadAsStreamAsync(); PlayerProfile profile = null; try { + var httpClient = HttpClientFactory.Create(); + var httpResponseMessage = await httpClient.GetAsync(playerDatabase.Profile + handshake.Fingerprint); + var result = await httpResponseMessage.Content.ReadAsStreamAsync(); + var yaml = MiniYaml.FromStream(result).First(); if (yaml.Key == "Player") { diff --git a/OpenRA.Mods.Common/WebServices.cs b/OpenRA.Mods.Common/WebServices.cs index b83db40507..dd5f57389f 100644 --- a/OpenRA.Mods.Common/WebServices.cs +++ b/OpenRA.Mods.Common/WebServices.cs @@ -40,20 +40,24 @@ namespace OpenRA.Mods.Common { "version", Game.ModData.Manifest.Metadata.Version } }.ToString(); - var client = HttpClientFactory.Create(); - - var httpResponseMessage = await client.GetAsync(queryURL); - var result = await httpResponseMessage.Content.ReadAsStringAsync(); - - var status = ModVersionStatus.Latest; - switch (result) + try { - case "outdated": status = ModVersionStatus.Outdated; break; - case "unknown": status = ModVersionStatus.Unknown; break; - case "playtest": status = ModVersionStatus.PlaytestAvailable; break; - } + var client = HttpClientFactory.Create(); - Game.RunAfterTick(() => ModVersionStatus = status); + var httpResponseMessage = await client.GetAsync(queryURL); + var result = await httpResponseMessage.Content.ReadAsStringAsync(); + + var status = ModVersionStatus.Latest; + switch (result) + { + case "outdated": status = ModVersionStatus.Outdated; break; + case "unknown": status = ModVersionStatus.Unknown; break; + case "playtest": status = ModVersionStatus.PlaytestAvailable; break; + } + + Game.RunAfterTick(() => ModVersionStatus = status); + } + catch { } }); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs index a8a2a69214..949079421d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackageLogic.cs @@ -235,12 +235,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic Task.Run(async () => { - var client = HttpClientFactory.Create(); - var httpResponseMessage = await client.GetAsync(download.MirrorList); - var result = await httpResponseMessage.Content.ReadAsStringAsync(); - try { + var client = HttpClientFactory.Create(); + var httpResponseMessage = await client.GetAsync(download.MirrorList); + var result = await httpResponseMessage.Content.ReadAsStringAsync(); + var mirrorList = result.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); downloadUrl(mirrorList.Random(new MersenneTwister())); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs index d519c8cf66..16852a4540 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ServerListLogic.cs @@ -343,16 +343,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic Task.Run(async () => { - var games = new List(); - var client = HttpClientFactory.Create(); - var httpResponseMessage = await client.GetAsync(queryURL); - var result = await httpResponseMessage.Content.ReadAsStreamAsync(); - + List games = null; activeQuery = true; try { + var client = HttpClientFactory.Create(); + var httpResponseMessage = await client.GetAsync(queryURL); + var result = await httpResponseMessage.Content.ReadAsStreamAsync(); + var yaml = MiniYaml.FromStream(result); + games = new List(); foreach (var node in yaml) { try