Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow the RetryDelegatingHandler to be used with HttpClientFactory #1030

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SendGrid/BaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public async Task<Response> RequestAsync(

private static HttpClient CreateHttpClientWithRetryHandler(BaseClientOptions options)
{
return new HttpClient(new RetryDelegatingHandler(options.ReliabilitySettings));
return new HttpClient(new RetryDelegatingHandler(new HttpClientHandler(), options.ReliabilitySettings));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/SendGrid/Reliability/RetryDelegatingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class RetryDelegatingHandler : DelegatingHandler
/// </summary>
/// <param name="settings">A ReliabilitySettings instance.</param>
public RetryDelegatingHandler(ReliabilitySettings settings)
: this(new HttpClientHandler(), settings)
{
this.settings = settings;
}

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion tests/SendGrid.Tests/Integration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5872,7 +5872,10 @@ public async Task TestRetryBehaviourThrowsTimeoutException()
ReliabilitySettings = new ReliabilitySettings(1, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(1))
};

var retryHandler = new RetryDelegatingHandler(new HttpClientHandler(), options.ReliabilitySettings);
var retryHandler = new RetryDelegatingHandler(options.ReliabilitySettings);

// Verify we can set the inner handler after constrcution.
retryHandler.InnerHandler = new HttpClientHandler();

HttpClient clientToInject = new HttpClient(retryHandler) { Timeout = TimeSpan.FromMilliseconds(1) };
var sg = new SendGridClient(clientToInject, options.ApiKey);
Expand Down