Skip to content

Commit 472ad92

Browse files
committed
Adjust updating of already initialized instance of an HttpClient
1 parent 751ed4f commit 472ad92

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Functions/Client.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Supabase.Functions
1919
/// <inheritdoc />
2020
public partial class Client : IFunctionsClient
2121
{
22-
private static readonly HttpClient HttpClient = new HttpClient();
22+
private HttpClient _httpClient = new HttpClient();
2323
private readonly string _baseUrl;
2424

2525
/// <summary>
@@ -126,10 +126,14 @@ private async Task<HttpResponseMessage> HandleRequest(string url, string? token
126126
{
127127
requestMessage.Headers.TryAddWithoutValidation(kvp.Key, kvp.Value);
128128
}
129-
130-
HttpClient.Timeout = options.HttpTimeout;
131129

132-
var response = await HttpClient.SendAsync(requestMessage);
130+
if (_httpClient.Timeout != options.HttpTimeout)
131+
{
132+
_httpClient = new HttpClient();
133+
_httpClient.Timeout = options.HttpTimeout;
134+
}
135+
136+
var response = await _httpClient.SendAsync(requestMessage);
133137

134138
if (response.IsSuccessStatusCode && !response.Headers.Contains("x-relay-error"))
135139
return response;

0 commit comments

Comments
 (0)