From 143c0b1e81efe4ee221cfb9771b666a6db66d112 Mon Sep 17 00:00:00 2001 From: thattuys <110502928+thattuys@users.noreply.github.com> Date: Tue, 2 Aug 2022 19:12:41 -0400 Subject: [PATCH] Support downloading from http Add http support to downloads(ws:// connections and uploads already work, this is just fixing the downloads) --- MareSynchronos/WebAPI/ApIController.Functions.Files.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MareSynchronos/WebAPI/ApIController.Functions.Files.cs b/MareSynchronos/WebAPI/ApIController.Functions.Files.cs index 6cd527e..8757795 100644 --- a/MareSynchronos/WebAPI/ApIController.Functions.Files.cs +++ b/MareSynchronos/WebAPI/ApIController.Functions.Files.cs @@ -55,7 +55,12 @@ namespace MareSynchronos.WebAPI wc.DownloadProgressChanged += progChanged; string fileName = Path.GetTempFileName(); - var baseUri = new Uri(ApiUri.Replace("wss", "https"), UriKind.Absolute); + Uri baseUri; + if (ApiUri.StartsWith("ws://")) { // Bad bad bad but yeah + baseUri = new Uri(ApiUri.Replace("ws", "http"), UriKind.Absolute); + } else { + baseUri = new Uri(ApiUri.Replace("wss", "https"), UriKind.Absolute); + } var relativeUri = new Uri("cache/" + hash, UriKind.Relative); var fileUri = new Uri(baseUri, relativeUri);