From 22e0884f74670b132bb47af7fce20bbcaec01808 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 28 Feb 2024 22:27:03 +0100 Subject: Alternate header handling for request headers --- MatrixMediaGate/Program.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MatrixMediaGate/Program.cs b/MatrixMediaGate/Program.cs index cef146f..9436230 100644 --- a/MatrixMediaGate/Program.cs +++ b/MatrixMediaGate/Program.cs @@ -25,9 +25,14 @@ async Task Proxy(HttpClient hc, ProxyConfiguration cfg, HttpContext ctx, ILogger var method = new HttpMethod(ctx.Request.Method); using var req = new HttpRequestMessage(method, path); + hc.DefaultRequestHeaders.Clear(); + req.Headers.Clear(); foreach (var header in ctx.Request.Headers) { - if (header.Key != "Accept-Encoding" && header.Key != "Content-Type" && header.Key != "Content-Length") + if (header.Key != "Accept-Encoding" && header.Key != "Content-Type" && header.Key != "Content-Length") { + // req.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); + req.Headers.Remove(header.Key); req.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); + } } req.Headers.Host = cfg.Host; -- cgit 1.5.1