Skip to content

Commit

Permalink
fix(router): Handle repeated headers in response
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmtm committed Jan 27, 2025
1 parent f342b2b commit 0f48af5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions router/core/header_rule_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
}
}
}
Expand Down

0 comments on commit 0f48af5

Please sign in to comment.