Plugins: Only set non-existing headers for core plugin requests (#78633)

* Only set non-existing headers

- Add test scenario

* Fix test
This commit is contained in:
Andreas Christou
2023-11-30 11:51:40 +00:00
committed by GitHub
parent af7de68c65
commit f26ad881ed
2 changed files with 34 additions and 1 deletions
@@ -50,7 +50,10 @@ func (m *HTTPClientMiddleware) applyHeaders(ctx context.Context, pReq any) conte
if h, ok := pReq.(backend.ForwardHTTPHeaders); ok {
for k, v := range h.GetHTTPHeaders() {
req.Header[k] = v
// Only set a header if it is not already set.
if req.Header.Get(k) == "" {
req.Header[k] = v
}
}
}