From b78b3e43f4ed79deafbaa0d913d520d7280a3cbb Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 1 Dec 2025 09:45:41 +0100 Subject: [PATCH] Add support for custom headers in HTTP requests Enhanced HTTP request handling by adding support for dynamically including custom headers from the `request.Headers` collection. Implemented a null check to ensure robustness and prevent null reference exceptions when processing headers. This change improves flexibility and customization of HTTP requests. --- .../RecActions/Commands/InvokeRecActionCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index 135700e..be24672 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -57,6 +57,10 @@ public class InvokeRecActionCommandHandler( ); } + if (request.Headers is not null) + foreach (var header in request.Headers) + httpReq.Headers.Add(header.Key, header.Value); + using var response = await http.SendAsync(httpReq, cancel); var body = await response.Content.ReadAsStringAsync(cancel); var headers = response.Headers.ToDictionary();