Skip to content

Commit

Permalink
Resolves #5 - Adds an HttpTimeout option to InvokeFunctionOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
acupofjose committed Mar 12, 2024
1 parent 4605d4e commit df1a783
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Functions/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ private async Task<HttpResponseMessage> HandleRequest(string url, string? token
requestMessage.Headers.TryAddWithoutValidation(kvp.Key, kvp.Value);
}

HttpClient.Timeout = options.HttpTimeout;

var response = await HttpClient.SendAsync(requestMessage);

if (response.IsSuccessStatusCode && !response.Headers.Contains("x-relay-error"))
Expand Down
12 changes: 9 additions & 3 deletions Functions/InvokeFunctionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Supabase.Functions
{

public partial class Client
{
/// <summary>
Expand All @@ -24,6 +24,12 @@ public class InvokeFunctionOptions
/// </summary>
[JsonProperty("body")]
public Dictionary<string, object> Body { get; set; } = new Dictionary<string, object>();

/// <summary>
/// Timout value for HttpClient Requests, defaults to 100s.
/// https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-8.0#remarks
/// </summary>
public TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(100);
}
}
}
}

0 comments on commit df1a783

Please sign in to comment.