Support downloading from http

Add http support to downloads(ws:// connections and uploads already work, this is just fixing the downloads)
This commit is contained in:
thattuys
2022-08-02 19:12:41 -04:00
committed by GitHub
parent 801969f0d2
commit 143c0b1e81

View File

@@ -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);