check to prevent possible key not found bug

This commit is contained in:
tmenier 2015-06-10 21:28:05 -05:00
parent 98b32d257b
commit ecacdd70c4

View File

@ -76,8 +76,10 @@ namespace Flurl.Http
get {
if (!Completed) return false;
if (Response.IsSuccessStatusCode) return true;
if (!Request.Properties.ContainsKey("AllowedHttpStatusRanges")) return false;
var allowedStatuses = Request.Properties["AllowedHttpStatusRanges"] as IEnumerable<string>;
return allowedStatuses != null && allowedStatuses.Any(s => HttpStatusRangeParser.IsMatch(s, Response.StatusCode));
if (allowedStatuses == null) return false;
return allowedStatuses.Any(s => HttpStatusRangeParser.IsMatch(s, Response.StatusCode));
}
}