From c6b195463453e1f4833271a58aa583efce8626ab Mon Sep 17 00:00:00 2001 From: Mike Goodfellow Date: Fri, 16 Apr 2021 09:21:58 +0100 Subject: [PATCH] Revert PR 9 changes --- .../Examples/Basic/BasicSendWithRetry.cs | 1 - src/SocketLabs/InjectionApi/Core/RetryHandler.cs | 2 +- src/SocketLabs/InjectionApi/SocketLabsClient.cs | 15 +++------------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Example Projects/dotNetCoreExample/Examples/Basic/BasicSendWithRetry.cs b/Example Projects/dotNetCoreExample/Examples/Basic/BasicSendWithRetry.cs index cf4024c..fd94242 100644 --- a/Example Projects/dotNetCoreExample/Examples/Basic/BasicSendWithRetry.cs +++ b/Example Projects/dotNetCoreExample/Examples/Basic/BasicSendWithRetry.cs @@ -14,7 +14,6 @@ public SendResponse RunExample() var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey, proxy) { EndpointUrl = ExampleConfig.TargetApi, - RequestTimeout = 120, NumberOfRetries = 3 }; diff --git a/src/SocketLabs/InjectionApi/Core/RetryHandler.cs b/src/SocketLabs/InjectionApi/Core/RetryHandler.cs index e6924fe..1462abf 100644 --- a/src/SocketLabs/InjectionApi/Core/RetryHandler.cs +++ b/src/SocketLabs/InjectionApi/Core/RetryHandler.cs @@ -53,7 +53,7 @@ public async Task SendAsync(StringContent content, Cancella { var response = await HttpClient.PostAsync(EndpointUrl, content, cancellationToken) .ConfigureAwait(false); - + if (ErrorStatusCodes.Contains(response.StatusCode)) throw new HttpRequestException( $"HttpStatusCode: '{response.StatusCode}'. Response contains server error."); diff --git a/src/SocketLabs/InjectionApi/SocketLabsClient.cs b/src/SocketLabs/InjectionApi/SocketLabsClient.cs index 6d61a00..562e775 100644 --- a/src/SocketLabs/InjectionApi/SocketLabsClient.cs +++ b/src/SocketLabs/InjectionApi/SocketLabsClient.cs @@ -43,12 +43,7 @@ public class SocketLabsClient : ISocketLabsClient, IDisposable /// The SocketLabs Injection API endpoint Url /// public string EndpointUrl { get; set; } = "https://inject.socketlabs.com/api/v1/email"; - - /// - /// A timeout period for the Injection API request (in Seconds). Default: 120s - /// - public int RequestTimeout { get; set; } = 120; - + /// /// RetrySettings object to define retry setting for the Injection API request. /// @@ -237,9 +232,7 @@ public async Task SendAsync(IBasicMessage message, CancellationTok var factory = new InjectionRequestFactory(_serverId, _apiKey); var injectionRequest = factory.GenerateRequest(message); var json = injectionRequest.GetAsJson(); - - _httpClient.Timeout = TimeSpan.FromSeconds(RequestTimeout); - + var retryHandler = new RetryHandler(_httpClient, EndpointUrl, new RetrySettings(NumberOfRetries)); var httpResponse = await retryHandler.SendAsync(json, cancellationToken); @@ -292,9 +285,7 @@ public async Task SendAsync(IBulkMessage message, CancellationToke var factory = new InjectionRequestFactory(_serverId, _apiKey); var injectionRequest = factory.GenerateRequest(message); var json = injectionRequest.GetAsJson(); - - _httpClient.Timeout = TimeSpan.FromSeconds(RequestTimeout); - + var retryHandler = new RetryHandler(_httpClient, EndpointUrl, new RetrySettings(NumberOfRetries)); var httpResponse = await retryHandler.SendAsync(json, cancellationToken);