From 114d8a7b96fc76d8f0e7381479d233d95d546189 Mon Sep 17 00:00:00 2001 From: nbitounisxe Date: Mon, 9 Dec 2024 12:28:03 +0200 Subject: [PATCH] We now ignore certain headers without trying to forward them to the destination. --- .../AWSRedrive.LinuxService.csproj | 2 +- Projects/AWSRedrive.console/AWSRedrive.console.csproj | 2 +- Projects/AWSRedrive/AWSRedrive.csproj | 2 +- Projects/AWSRedrive/HttpMessageProcessor.cs | 11 +++++++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Projects/AWSRedrive.LinuxService/AWSRedrive.LinuxService.csproj b/Projects/AWSRedrive.LinuxService/AWSRedrive.LinuxService.csproj index 7a1c807..1d12a73 100644 --- a/Projects/AWSRedrive.LinuxService/AWSRedrive.LinuxService.csproj +++ b/Projects/AWSRedrive.LinuxService/AWSRedrive.LinuxService.csproj @@ -3,7 +3,7 @@ net8.0 {E2CEBBAF-6DF7-41E9-815D-9AD4CF90C845} - 1.0.13 + 1.0.14 diff --git a/Projects/AWSRedrive.console/AWSRedrive.console.csproj b/Projects/AWSRedrive.console/AWSRedrive.console.csproj index 44accd3..34fe1da 100644 --- a/Projects/AWSRedrive.console/AWSRedrive.console.csproj +++ b/Projects/AWSRedrive.console/AWSRedrive.console.csproj @@ -3,7 +3,7 @@ Exe net8.0 - 1.0.13 + 1.0.14 diff --git a/Projects/AWSRedrive/AWSRedrive.csproj b/Projects/AWSRedrive/AWSRedrive.csproj index 2fc1a78..d565c9d 100644 --- a/Projects/AWSRedrive/AWSRedrive.csproj +++ b/Projects/AWSRedrive/AWSRedrive.csproj @@ -3,7 +3,7 @@ net8.0 {E2CEBBAF-6DF7-41E9-815D-9AD4CF90C844} - 1.0.13 + 1.0.14 diff --git a/Projects/AWSRedrive/HttpMessageProcessor.cs b/Projects/AWSRedrive/HttpMessageProcessor.cs index bbcdc71..d957529 100644 --- a/Projects/AWSRedrive/HttpMessageProcessor.cs +++ b/Projects/AWSRedrive/HttpMessageProcessor.cs @@ -14,6 +14,7 @@ namespace AWSRedrive public class HttpMessageProcessor : IMessageProcessor { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private readonly string[] _ignoredHeaders = ["content-length", "host", "accept-encoding", "content-type", "accept"]; public void ProcessMessage(string message, Dictionary attributes, ConfigurationEntry configurationEntry) { @@ -55,7 +56,10 @@ public void UnpackAttributesAsHeaders(string message, RestRequest request, Confi var value = attribute.Value.Value.ToString(); if (!string.IsNullOrEmpty(value)) { - request.AddHeader(attribute.Key, value); + if (!_ignoredHeaders.Contains(attribute.Key.ToLower())) + { + request.AddHeader(attribute.Key, value); + } } } } @@ -144,7 +148,10 @@ public void AddAttributes(RestRequest request, Dictionary attrib { foreach (var key in attributes.Keys.Where(key => !string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(attributes[key]))) { - request.AddHeader(key, attributes[key]); + if (!_ignoredHeaders.Contains(key.ToLower())) + { + request.AddHeader(key, attributes[key]); + } } } }