From e2f6c6f837d31afe8e69436201e3784787b79ecc Mon Sep 17 00:00:00 2001 From: Renee Mundie Date: Tue, 6 May 2025 15:19:37 +1000 Subject: [PATCH] Fix unsafe enumeration in HttpRequestHeadersExtensions.Fill to prevent InvalidOperationException --- algoliasearch/Http/HttpRequestHeadersExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/algoliasearch/Http/HttpRequestHeadersExtensions.cs b/algoliasearch/Http/HttpRequestHeadersExtensions.cs index 7b56a5ead..b37c772ce 100644 --- a/algoliasearch/Http/HttpRequestHeadersExtensions.cs +++ b/algoliasearch/Http/HttpRequestHeadersExtensions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Net.Http.Headers; using Algolia.Search.Utils; @@ -14,7 +15,7 @@ internal static class HttpRequestHeadersExtensions /// internal static void Fill(this HttpRequestHeaders headers, IDictionary dictionary) { - foreach (var header in dictionary) + foreach (var header in dictionary.ToList()) { headers.TryAddWithoutValidation(header.Key, header.Value); }