From 62887e76a8ba97507fdeda45819e8d4f96600db8 Mon Sep 17 00:00:00 2001
From: Pjort Kat <pjort.kat@gmail.com>
Date: Thu, 25 Jul 2024 16:08:57 +0200
Subject: [PATCH 1/3] chore: Add custom headers from options in Client.cs

---
 Supabase/Client.cs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Supabase/Client.cs b/Supabase/Client.cs
index 57a3012f..b607afaa 100644
--- a/Supabase/Client.cs
+++ b/Supabase/Client.cs
@@ -244,7 +244,7 @@ private void Auth_StateChanged(object sender, AuthState e)
         /// <inheritdoc />
         public Task<BaseResponse> Rpc(string procedureName, object? parameters) =>
             _postgrest.Rpc(procedureName, parameters);
-        
+
         /// <inheritdoc />
         public Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters) =>
             _postgrest.Rpc<TModeledResponse>(procedureName, parameters);
@@ -272,6 +272,13 @@ internal Dictionary<string, string> GetAuthHeaders()
                 headers["Authorization"] = $"Bearer {bearer}";
             }
 
+            // Add custom headers from options
+            // This will overwrite any existing headers with the same key, not sure if that's the desired behavior
+            foreach (var (key, value) in _options.Headers)
+            {
+                headers[key] = value;
+            }
+
             return headers;
         }
     }

From 037d7de98e4d46111527e9cca3eaa3c96c3356c1 Mon Sep 17 00:00:00 2001
From: Pjort Kat <pjort.kat@gmail.com>
Date: Thu, 25 Jul 2024 20:28:54 +0200
Subject: [PATCH 2/3] fixed to work with netstandard2.0

---
 Supabase/Client.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Supabase/Client.cs b/Supabase/Client.cs
index b607afaa..898e2ea1 100644
--- a/Supabase/Client.cs
+++ b/Supabase/Client.cs
@@ -274,9 +274,9 @@ internal Dictionary<string, string> GetAuthHeaders()
 
             // Add custom headers from options
             // This will overwrite any existing headers with the same key, not sure if that's the desired behavior
-            foreach (var (key, value) in _options.Headers)
+            foreach (var kvp in _options.Headers)
             {
-                headers[key] = value;
+                headers[kvp.Key] = kvp.Value;
             }
 
             return headers;

From 429ab5999fed944061c919a1e843e4ba8fdeb629 Mon Sep 17 00:00:00 2001
From: Joseph Schultz <9093699+acupofjose@users.noreply.github.com>
Date: Thu, 25 Jul 2024 13:48:27 -0500
Subject: [PATCH 3/3] Update comments

---
 Supabase/Client.cs | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/Supabase/Client.cs b/Supabase/Client.cs
index 898e2ea1..fecadf65 100644
--- a/Supabase/Client.cs
+++ b/Supabase/Client.cs
@@ -249,6 +249,9 @@ public Task<BaseResponse> Rpc(string procedureName, object? parameters) =>
         public Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters) =>
             _postgrest.Rpc<TModeledResponse>(procedureName, parameters);
 
+        /// <summary>
+        /// Produces dictionary of Headers that will be supplied to child clients.
+        ///</summary>
         internal Dictionary<string, string> GetAuthHeaders()
         {
             var headers = new Dictionary<string, string>
@@ -257,9 +260,7 @@ internal Dictionary<string, string> GetAuthHeaders()
             };
 
             if (_supabaseKey != null)
-            {
                 headers["apiKey"] = _supabaseKey;
-            }
 
             // In Regard To: https://github.com/supabase/supabase-csharp/issues/5
             if (_options.Headers.TryGetValue("Authorization", out var header))
@@ -272,14 +273,11 @@ internal Dictionary<string, string> GetAuthHeaders()
                 headers["Authorization"] = $"Bearer {bearer}";
             }
 
-            // Add custom headers from options
-            // This will overwrite any existing headers with the same key, not sure if that's the desired behavior
+            // Add supplied headers from `ClientOptions` by developer
             foreach (var kvp in _options.Headers)
-            {
                 headers[kvp.Key] = kvp.Value;
-            }
 
             return headers;
         }
     }
-}
\ No newline at end of file
+}