check to prevent possible key not found bug
This commit is contained in:
parent
98b32d257b
commit
ecacdd70c4
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user