From cf630656810aae9dd92889834d132cf8acd7f687 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 6 Jan 2019 19:20:24 +0100 Subject: [PATCH] Implement redirection RFC in WebBrowser --- ArchiSteamFarm.sln.DotSettings | 2 ++ ArchiSteamFarm/WebBrowser.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings index 00086a4f3..986e91548 100644 --- a/ArchiSteamFarm.sln.DotSettings +++ b/ArchiSteamFarm.sln.DotSettings @@ -522,6 +522,7 @@ limitations under the License. <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="I" Suffix="" Style="AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="_" Suffix="" Style="AaBb" /><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="_" Suffix="" Style="AaBb" /><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy> + False LIVE_MONITOR LIVE_MONITOR LIVE_MONITOR @@ -547,6 +548,7 @@ limitations under the License. True True True + True True True True diff --git a/ArchiSteamFarm/WebBrowser.cs b/ArchiSteamFarm/WebBrowser.cs index 3f1bf5087..a359715a5 100644 --- a/ArchiSteamFarm/WebBrowser.cs +++ b/ArchiSteamFarm/WebBrowser.cs @@ -505,6 +505,20 @@ namespace ArchiSteamFarm { redirectUri = new Uri(requestUri.GetLeftPart(UriPartial.Authority) + redirectUri); } + // According to the RFC, POST requests in certain types of redirection must be converted into GET + if (httpMethod == HttpMethod.Post) { + switch (response.StatusCode) { + case HttpStatusCode.Found: + case HttpStatusCode.Moved: + case HttpStatusCode.MultipleChoices: + case HttpStatusCode.SeeOther: + httpMethod = HttpMethod.Get; + data = null; + + break; + } + } + response.Dispose(); return await InternalRequest(redirectUri, httpMethod, data, referer, httpCompletionOption, --maxRedirections).ConfigureAwait(false);