private static FeedVerificationResult HandleWebException(WebException exception, string source)
{
try
{
var httpWebResponse = (HttpWebResponse)exception.Response;
if (ReferenceEquals(httpWebResponse, null))
{
return FeedVerificationResult.Invalid;
}
if ((int)httpWebResponse.StatusCode == 403)
{
return FeedVerificationResult.Valid;
}
if (exception.Status == WebExceptionStatus.ProtocolError)
{
return httpWebResponse.StatusCode == HttpStatusCode.Unauthorized
? FeedVerificationResult.AuthenticationRequired
: FeedVerificationResult.Invalid;
}
}
catch (Exception ex)
{
Log.Debug(ex, "Failed to verify feed '{0}'", source);
}
return FeedVerificationResult.Invalid;
}
#endregion