SEBWIN-362: Implemented fallback mechanism in case HEAD requests do not work for certain network resources.
This commit is contained in:
parent
246bc81d79
commit
3840fb4e84
1 changed files with 12 additions and 1 deletions
|
@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue