SEBWIN-362: Implemented fallback mechanism in case HEAD requests do not work for certain network resources.

This commit is contained in:
Damian Büchel 2020-03-30 11:49:47 +02:00
parent 246bc81d79
commit 3840fb4e84

View file

@ -163,6 +163,17 @@ namespace SafeExamBrowser.Configuration.DataResources
logger.Debug($"Received response '{ToString(response)}'.");
if (!isAvailable)
{
logger.Debug($"HEAD request was not successful, trying GET request for '{uri}'...");
request = new HttpRequestMessage(HttpMethod.Get, uri);
response = Execute(request);
isAvailable = response.IsSuccessStatusCode || IsUnauthorized(response);
logger.Debug($"Received response '{ToString(response)}'.");
}
return isAvailable;
}
catch (Exception e)
@ -180,7 +191,7 @@ namespace SafeExamBrowser.Configuration.DataResources
private string ToString(HttpResponseMessage response)
{
return $"{(int)response.StatusCode} - {response.ReasonPhrase}";
return $"{(int) response.StatusCode} - {response.ReasonPhrase}";
}
}
}