Skip to content

fix: handle multi-value response headers as comma-separated per RFC 7230#6281

Closed
patrostkowski wants to merge 1 commit intoenvoyproxy:mainfrom
patrostkowski:fix/many-headers-5733
Closed

fix: handle multi-value response headers as comma-separated per RFC 7230#6281
patrostkowski wants to merge 1 commit intoenvoyproxy:mainfrom
patrostkowski:fix/many-headers-5733

Conversation

@patrostkowski
Copy link
Copy Markdown
Contributor

@patrostkowski patrostkowski commented Jun 9, 2025

What type of PR is this?

fix

What this PR does / why we need it:

This change updates the translation logic of ResponseHeaderModifier so that when multiple values are specified for a header, they are joined into a single, comma-separated value as required by RFC 7230. As a result, the generated Envoy config now emits one HeaderValueOption per header, with all values joined by commas.

Tested using following config:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: backend
  namespace: default
spec:
  hostnames:
  - www.example.com
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: eg
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: backend
      port: 3000
      weight: 1
    filters:
    - responseHeaderModifier:
        set:
        - name: Cache-Control
          value: private, no-store
      type: ResponseHeaderModifier
    matches:
    - path:
        type: PathPrefix
        value: /
# curl latest image
root@ubuntu:/$ curl -i http://10.96.20.98/ -H 'Host: www.example.com' -H 'X-Echo-Set-Header: Cache-control: value1' | grep ^cache-control
cache-control:  no-store

# curl e4c8f89 image
root@ubuntu:/$ curl -i http://10.96.20.98/ -H 'Host: www.example.com' -H 'X-Echo-Set-Header: Cache-control: value1' | grep ^cache-control
cache-control: private, no-store

Which issue(s) this PR fixes:

Fixes #5733

Release Notes: Yes/No

@patrostkowski patrostkowski force-pushed the fix/many-headers-5733 branch from e5a23eb to 48cc475 Compare June 9, 2025 20:51
@patrostkowski patrostkowski marked this pull request as ready for review June 9, 2025 20:52
@patrostkowski patrostkowski requested a review from a team as a code owner June 9, 2025 20:52
Comment thread internal/xds/translator/route.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break the logic for requestHeaders

for responseHeaders, is the fix to avoid the split in the gateway-api layer

Value: strings.Split(addHeader.Value, ","),
?

please add a test case in the gateway-api and xds/translator layer

@patrostkowski patrostkowski force-pushed the fix/many-headers-5733 branch from 48cc475 to e4c8f89 Compare June 12, 2025 17:01
@patrostkowski patrostkowski changed the title fix: handle multi-value headers as comma-separated per RFC 7230 fix: handle multi-value response headers as comma-separated per RFC 7230 Jun 12, 2025
@patrostkowski patrostkowski force-pushed the fix/many-headers-5733 branch from ac27d4e to 9c144f6 Compare June 12, 2025 17:08
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Jun 12, 2025

hey @patrostkowski we use YAML based testcases for better readability

  • e.g. for gateway-api lib - internal/gatewayapi/testdata/grpcroute-with-request-header-modifier.in.yaml
  • for xds translator - internal/xds/translator/testdata/in/xds-ir/http-route-request-headers.yaml

if you run make testdata it will even generate the out files for you

This change updates response header modifier handling to comply with RFC 7230 by
preserving header values containing commas as single strings. Request header
behavior remains unchanged to avoid breaking existing functionality.

Signed-off-by: Patryk Rostkowski <patrostkowski@gmail.com>
@patrostkowski patrostkowski force-pushed the fix/many-headers-5733 branch from 9c144f6 to 2b8a179 Compare June 13, 2025 11:18
@patrostkowski
Copy link
Copy Markdown
Contributor Author

@arkodg sure, let me adjust the tests then

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.66%. Comparing base (e0e8a29) to head (2b8a179).
⚠️ Report is 589 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6281      +/-   ##
==========================================
+ Coverage   70.60%   70.66%   +0.06%     
==========================================
  Files         220      220              
  Lines       36829    36832       +3     
==========================================
+ Hits        26004    26029      +25     
+ Misses       9292     9275      -17     
+ Partials     1533     1528       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Jul 13, 2025
@github-actions github-actions Bot removed the stale label Jul 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 29, 2025
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Sep 15, 2025

@patrostkowski still working on this ?

@github-actions github-actions Bot removed the stale label Sep 16, 2025
@jasmin-terrien
Copy link
Copy Markdown

@patrostkowski any news/time to finish your fix ?

@VonNao
Copy link
Copy Markdown

VonNao commented Oct 30, 2025

This still seems to be worked on right?

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Oct 30, 2025

@jasmin-terrien @VonNao feel free to pick this one up, there's been inactivity for a long time

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Nov 14, 2025

fixed with #7436

@arkodg arkodg closed this Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResponseHeaderModifier does not permit to set a content with commas

5 participants