Skip to content

Commit

Permalink
Fix HttpClientFactory;
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Aug 30, 2022
1 parent fa67cf7 commit b0196e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Matrix.Sdk/Core/Infrastructure/Services/BaseApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public abstract class BaseApiService
private readonly IHttpClientFactory _httpClientFactory;

public Uri? BaseAddress { get; set; }
private static TimeSpan DefaultTimeout => TimeSpan.FromMilliseconds(Constants.LaterSyncTimout + 10000);

protected BaseApiService(IHttpClientFactory httpClientFactory)
{
Expand All @@ -26,7 +27,7 @@ protected BaseApiService(IHttpClientFactory httpClientFactory)
/// <returns>HttpClient</returns>
protected HttpClient CreateHttpClient(string? accessToken = null)
{
HttpClient httpClient = _httpClientFactory.CreateClient(Constants.Matrix);
var httpClient = _httpClientFactory.CreateClient(Constants.Matrix);

if (accessToken != null)
httpClient.AddBearerToken(accessToken);
Expand All @@ -37,7 +38,8 @@ protected HttpClient CreateHttpClient(string? accessToken = null)
if (httpClient.BaseAddress == null)
httpClient.BaseAddress = BaseAddress;

httpClient.Timeout = TimeSpan.FromMilliseconds(Constants.LaterSyncTimout + 10000);
if (httpClient.Timeout != DefaultTimeout)
httpClient.Timeout = DefaultTimeout;

return httpClient;
}
Expand Down
2 changes: 1 addition & 1 deletion Matrix.Sdk/Matrix.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Authors>Mikhail Tatarenko</Authors>
<Product>Matrix.Sdk</Product>
<Description>This open-source library allows you to build .NET apps compatible with Matrix Protocol - http://www.matrix.org.</Description>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<Copyright>Copyright © Baking Bad 2019-2022</Copyright>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down

0 comments on commit b0196e2

Please sign in to comment.