Skip to content

Commit 6cce267

Browse files
committed
Refactor: Reduced duplication
1 parent 61d8f18 commit 6cce267

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/SendGrid/SendGridClient.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public SendGridClient(IWebProxy webProxy, string apiKey, string host = null, Dic
7474
}
7575
else
7676
{
77-
client = new HttpClient(new RetryDelegatingHandler(options.ReliabilitySettings));
77+
client = CreateHttpClientWithRetryHandler();
7878
}
7979

8080
InitiateClient(apiKey, host, requestHeaders, version, urlPath);
@@ -104,7 +104,7 @@ public SendGridClient(HttpClient httpClient, SendGridClientOptions options)
104104
}
105105

106106
this.options = options;
107-
client = (httpClient == null) ? new HttpClient(new RetryDelegatingHandler(options.ReliabilitySettings)) : httpClient;
107+
client = (httpClient == null) ? CreateHttpClientWithRetryHandler() : httpClient;
108108

109109
InitiateClient(options.ApiKey, options.Host, options.RequestHeaders, options.Version, options.UrlPath);
110110
}
@@ -193,6 +193,11 @@ private void InitiateClient(string apiKey, string host, Dictionary<string, strin
193193
}
194194
}
195195

196+
private HttpClient CreateHttpClientWithRetryHandler()
197+
{
198+
return new HttpClient(new RetryDelegatingHandler(options.ReliabilitySettings));
199+
}
200+
196201
/// <summary>
197202
/// The supported API methods.
198203
/// </summary>

0 commit comments

Comments
 (0)