Workaround for forum returning 203 when KiwiFlare is off for some reason

This commit is contained in:
barelyprofessional
2025-07-22 22:57:23 -05:00
parent a88449ddab
commit 28fd41d511

View File

@@ -84,13 +84,17 @@ public class KfTokenService
await CheckClearanceToken(); await CheckClearanceToken();
using var client = new HttpClient(GetHttpClientHandler()); using var client = new HttpClient(GetHttpClientHandler());
var response = await client.GetAsync($"https://{_kfDomain}/login", _ctx); var response = await client.GetAsync($"https://{_kfDomain}/login", _ctx);
if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation) response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStreamAsync(_ctx);
var document = new HtmlDocument();
document.Load(content);
var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]");
if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation && challengeData != null)
{ {
_logger.Error("Caught a 203 response when trying to load logon page which means we were KiwiFlare challenged"); _logger.Error("Caught a 203 response when trying to load logon page which means we were KiwiFlare challenged");
throw new KiwiFlareChallengedException(); throw new KiwiFlareChallengedException();
} }
response.EnsureSuccessStatusCode(); return content;
return await response.Content.ReadAsStreamAsync(_ctx);
} }
public async Task<bool> IsLoggedIn() public async Task<bool> IsLoggedIn()