Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions router/core/header_rule_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func WithResponseHeaderPropagation(ctx *resolve.Context) *resolve.Context {
}

func getResponseHeaderPropagation(ctx context.Context) *responseHeaderPropagation {
if ctx == nil {
return nil
}
v := ctx.Value(responseHeaderPropagationKey{})
if v == nil {
return nil
Expand Down
10 changes: 10 additions & 0 deletions router/core/header_rule_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ func TestPropagatedHeaders(t *testing.T) {
})
}

func TestGetResponseHeaderPropagation_NilContext(t *testing.T) {
t.Parallel()

// Ensure nil context does not panic (regression test for #2530)
assert.NotPanics(t, func() {
result := getResponseHeaderPropagation(nil)
assert.Nil(t, result)
})
}

func TestNewHeaderPropagation(t *testing.T) {
t.Parallel()

Expand Down
Loading