Flurl + Polly = resilient and easy HTTP requests.
var policy = Policy
.HandleResult<HttpResponseMessage>(message =>
{
var content = message.Content.ReadAsStringAsync().Result;
return content == "Bad Request";
})
.RetryAsync();
var response = await "http://www.google.com"
.WithPolicy(policy)
.GetAsync();
response.StatusCode.Should().Be(200);
built in transient retry handler
var response = await "http://www.google.com".RetryTransientErrors().GetAsync();
See Basic Tests for more examples.
- Option for global configuration (asp.net core http client factory)