Skip to content

HTTPHeaderFilter processing doesn't correctly support multiple header values. #4023

@liorokman

Description

@liorokman

Description:

The documentation for HTTPHeaderFilter contains this statement:

Configuration to set or add multiple values for a header must use RFC 7230 header value formatting, separating each value with a comma.

My expectation that adding a header via Envoy Gateway's route filters with a comma-delimited value would add the header in the same way that specifying the header multiple times with curl would do.

Repro steps:

  1. Deploy the quickstart example

  2. Apply the following HTTPRoute:

    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:
        - requestHeaderModifier:
            add:
            - name: add-header
              value: foo,bar
          type: RequestHeaderModifier
        matches:
        - path:
            type: PathPrefix
            value: /
  3. Run the following curl command:

    curl http://${ENVOY_GATEWAY_IP}/headers -H 'Host: www.example.com' -H 'Test: one' -H 'Test: two'

    Compare the header Add-Header and the header Test in the output:

    {
     "path": "/headers",
     "host": "www.example.com",
     "method": "GET",
     "proto": "HTTP/1.1",
     "headers": {
      "Accept": [
       "*/*"
      ],
      "Add-Header": [
       "foo,bar"
      ],
      "Test": [
       "one",
       "two"
      ],
     },
     "namespace": "default",
     "ingress": "",
     "service": "",
     "pod": "backend-96f75bbf-778l6"
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions