Skip to content

Commit df1a783

Browse files
committed
Resolves #5 - Adds an HttpTimeout option to InvokeFunctionOptions
1 parent 4605d4e commit df1a783

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Functions/Client.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ private async Task<HttpResponseMessage> HandleRequest(string url, string? token
127127
requestMessage.Headers.TryAddWithoutValidation(kvp.Key, kvp.Value);
128128
}
129129

130+
HttpClient.Timeout = options.HttpTimeout;
131+
130132
var response = await HttpClient.SendAsync(requestMessage);
131133

132134
if (response.IsSuccessStatusCode && !response.Headers.Contains("x-relay-error"))

Functions/InvokeFunctionOptions.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Newtonsoft.Json;
1+
using System;
2+
using Newtonsoft.Json;
23
using System.Collections.Generic;
34

45
namespace Supabase.Functions
56
{
6-
77
public partial class Client
88
{
99
/// <summary>
@@ -24,6 +24,12 @@ public class InvokeFunctionOptions
2424
/// </summary>
2525
[JsonProperty("body")]
2626
public Dictionary<string, object> Body { get; set; } = new Dictionary<string, object>();
27+
28+
/// <summary>
29+
/// Timout value for HttpClient Requests, defaults to 100s.
30+
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-8.0#remarks
31+
/// </summary>
32+
public TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(100);
2733
}
2834
}
29-
}
35+
}

0 commit comments

Comments
 (0)