Add a workaround for invalid scheme redirections

https://github.com/JustArchi/ArchiSteamFarm/issues/586#issuecomment-319422864
This commit is contained in:
JustArchi
2017-08-01 18:59:10 +02:00
parent aacc0a1720
commit f4f7935d4c

View File

@@ -535,11 +535,18 @@ namespace ArchiSteamFarm {
ushort status = (ushort) responseMessage.StatusCode;
if ((status >= 300) && (status <= 399) && (maxRedirections > 0)) {
redirectUri = responseMessage.Headers.Location;
switch (redirectUri.Scheme) {
case "http":
case "https":
break;
default:
// Invalid ones such as "steammobile"
return null;
}
if (!redirectUri.IsAbsoluteUri) {
redirectUri = new Uri(requestUri.GetLeftPart(UriPartial.Authority) + redirectUri);
}
ASF.ArchiLogger.LogGenericDebug("Asked for <" + requestUri + ">, got unsafely redirected to <" + responseMessage.Headers.Location + ">, resolved URI to: <" + redirectUri + ">");
} else {
if (!Debugging.IsDebugBuild) {
return null;