diff --git a/src/Postmark.Tests/ClientMessageClickQueryTests.cs b/src/Postmark.Tests/ClientMessageClickQueryTests.cs index 8e98a5b..0f4f4d2 100644 --- a/src/Postmark.Tests/ClientMessageClickQueryTests.cs +++ b/src/Postmark.Tests/ClientMessageClickQueryTests.cs @@ -10,7 +10,7 @@ public class ClientMessageClickQueryTests : ClientBaseFixture { protected override void Setup() { - _client = new PostmarkClient(READ_LINK_TRACKING_TEST_SERVER_TOKEN, requestTimeoutInSeconds: 60); + _client = new PostmarkClient(READ_LINK_TRACKING_TEST_SERVER_TOKEN); } [Fact] diff --git a/src/Postmark.Tests/ClientMessageOpenQueryTests.cs b/src/Postmark.Tests/ClientMessageOpenQueryTests.cs index deceef5..a0f868d 100644 --- a/src/Postmark.Tests/ClientMessageOpenQueryTests.cs +++ b/src/Postmark.Tests/ClientMessageOpenQueryTests.cs @@ -10,7 +10,7 @@ public class ClientMessageOpenQueryTests : ClientBaseFixture { protected override void Setup() { - _client = new PostmarkClient(READ_SELENIUM_OPEN_TRACKING_TOKEN, requestTimeoutInSeconds: 60); + _client = new PostmarkClient(READ_SELENIUM_OPEN_TRACKING_TOKEN); } [Fact] diff --git a/src/Postmark.Tests/ClientMessageSearchingTests.cs b/src/Postmark.Tests/ClientMessageSearchingTests.cs index fa246b6..e89aed0 100644 --- a/src/Postmark.Tests/ClientMessageSearchingTests.cs +++ b/src/Postmark.Tests/ClientMessageSearchingTests.cs @@ -11,7 +11,7 @@ public class ClientMessageSearchingTests : ClientBaseFixture { protected override void Setup() { - _client = new PostmarkClient(READ_SELENIUM_TEST_SERVER_TOKEN, requestTimeoutInSeconds: 60); + _client = new PostmarkClient(READ_SELENIUM_TEST_SERVER_TOKEN); } [Fact] diff --git a/src/Postmark/ISimpleHttpClient.cs b/src/Postmark/ISimpleHttpClient.cs index 280c452..730e429 100644 --- a/src/Postmark/ISimpleHttpClient.cs +++ b/src/Postmark/ISimpleHttpClient.cs @@ -6,8 +6,6 @@ namespace PostmarkDotNet { public interface ISimpleHttpClient { - TimeSpan Timeout { get; set; } - Task SendAsync(HttpRequestMessage request); } } \ No newline at end of file diff --git a/src/Postmark/PostmarkAdminClient.cs b/src/Postmark/PostmarkAdminClient.cs index 3ec97ed..c97b95c 100644 --- a/src/Postmark/PostmarkAdminClient.cs +++ b/src/Postmark/PostmarkAdminClient.cs @@ -18,10 +18,9 @@ public class PostmarkAdminClient : PostmarkDotNet.PostmarkClientBase /// Construct a PostmarkAdminClient. /// /// The "accountToken" can be found by logging into your Postmark and navigating to https://postmarkapp.com/account/edit - Keep this token secret and safe. - /// The number of seconds to wait for the API to return before throwing a timeout exception. /// Optionally override the base url to the API. For example, you may fallback to HTTP (non-SSL) if your app requires it, though, this is not recommended. - public PostmarkAdminClient(string accountToken, int requestTimeoutInSeconds = 30, string apiBaseUri = "https://api.postmarkapp.com") - : base(apiBaseUri, requestTimeoutInSeconds) + public PostmarkAdminClient(string accountToken, string apiBaseUri = "https://api.postmarkapp.com") + : base(apiBaseUri) { _authToken = accountToken; } diff --git a/src/Postmark/PostmarkClient.cs b/src/Postmark/PostmarkClient.cs index cbc8c44..88e1948 100644 --- a/src/Postmark/PostmarkClient.cs +++ b/src/Postmark/PostmarkClient.cs @@ -29,10 +29,9 @@ protected override string AuthHeaderName /// Instantiate the client. /// /// The base uri to use when connecting to Postmark. You should rarely need to modify this, except if you want to disable TLS (not recommended), or you are using a proxy of some sort to connect to the API. - /// The length of time to wait for an API request to complete. In most cases, this should not be modified. If your requests are timing out (for example, large batch submissions, you should consider reducing the size or number of messages you are submitting at one time before increasing this value). /// Used for requests that require server level privileges. This token can be found on the Credentials tab under your Postmark server. - public PostmarkClient(string serverToken, string apiBaseUri = "https://api.postmarkapp.com", int requestTimeoutInSeconds = 30) - : base(apiBaseUri, requestTimeoutInSeconds) + public PostmarkClient(string serverToken, string apiBaseUri = "https://api.postmarkapp.com") + : base(apiBaseUri) { _authToken = serverToken; } diff --git a/src/Postmark/PostmarkClientBase.cs b/src/Postmark/PostmarkClientBase.cs index dc53900..6155f05 100644 --- a/src/Postmark/PostmarkClientBase.cs +++ b/src/Postmark/PostmarkClientBase.cs @@ -39,16 +39,14 @@ public abstract class PostmarkClientBase /// /// /// - public PostmarkClientBase(string apiBaseUri = "https://api.postmarkapp.com", int requestTimeoutInSeconds = 30) + public PostmarkClientBase(string apiBaseUri = "https://api.postmarkapp.com") { baseUri = new Uri(apiBaseUri); - _requestTimeout = requestTimeoutInSeconds; } protected abstract string AuthHeaderName { get; } protected string _authToken; - private int _requestTimeout; /// /// The core delivery method for all other API methods. @@ -81,8 +79,6 @@ protected async Task ProcessRequestAsync(str request.Headers.Add(AuthHeaderName, _authToken); request.Headers.Add("User-Agent", _agent); - client.Timeout = TimeSpan.FromSeconds(this._requestTimeout); - var result = await client.SendAsync(request); var body = await result.Content.ReadAsStringAsync(); diff --git a/src/Postmark/SimpleHttpClient.cs b/src/Postmark/SimpleHttpClient.cs index 7ab65fd..0764ca9 100644 --- a/src/Postmark/SimpleHttpClient.cs +++ b/src/Postmark/SimpleHttpClient.cs @@ -8,16 +8,8 @@ internal class SimpleHttpClient : ISimpleHttpClient { private HttpClient _client = new HttpClient(); - public TimeSpan Timeout - { - get - { - return _client.Timeout; - } - set - { - _client.Timeout = value; - } + public SimpleHttpClient(TimeSpan? timeoutLength = null){ + _client.Timeout = timeoutLength ?? TimeSpan.FromSeconds(30); } public Task SendAsync(HttpRequestMessage request)