From 0f48af5eb3d85f9c1aeed4d6134882ed15fddf94 Mon Sep 17 00:00:00 2001 From: Chris Morin Date: Mon, 27 Jan 2025 12:22:47 -0800 Subject: [PATCH] fix(router): Handle repeated headers in response When multiple headers with the same name were sent in the response from a subgraph, only one would be included in the response to the client when forwarding headers. Fix it so that they're all forwarded. --- router/core/header_rule_engine.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/router/core/header_rule_engine.go b/router/core/header_rule_engine.go index b3e7bcdc11..522a12dc28 100644 --- a/router/core/header_rule_engine.go +++ b/router/core/header_rule_engine.go @@ -309,9 +309,11 @@ func (h *HeaderPropagation) applyResponseRule(propagation *responseHeaderPropaga return } - value := res.Header.Get(rule.Named) - if value != "" { - h.applyResponseRuleKeyValue(res, propagation, rule, rule.Named, value) + values := res.Header.Values(rule.Named) + if len(values) > 0 { + for _, value := range values { + h.applyResponseRuleKeyValue(res, propagation, rule, rule.Named, value) + } } else if rule.Default != "" { h.applyResponseRuleKeyValue(res, propagation, rule, rule.Named, rule.Default) } @@ -324,7 +326,11 @@ func (h *HeaderPropagation) applyResponseRule(propagation *responseHeaderPropaga if slices.Contains(ignoredHeaders, name) { continue } - h.applyResponseRuleKeyValue(res, propagation, rule, name, res.Header.Get(name)) + + values := res.Header.Values(name) + for _, value := range values { + h.applyResponseRuleKeyValue(res, propagation, rule, name, value) + } } } }