PreserveCase plugin

Updated at:

By default, Envoy normalizes all HTTP/1.1 request and response header keys to lowercase. This can break applications that depend on case-sensitive headers. After you enable the PreserveCase plugin, the gateway and sidecar preserve the original case of forwarded request and response headers. This resolves service mesh dependency issues for case-sensitive applications.

Important
  • Enabling the PreserveCase plugin overrides the connection pool settings that you configure in a destination rule. Enable this plugin with caution.

  • ASM instances running version 1.25 or later can preserve request and response header case without this plugin. For more information, see Related information.

Configuration fields

Parameter

Type

Required

Default

Description

request_or_response

string

Yes

N/A

Specifies whether to preserve the case of request headers, response headers, or both. Valid values:

  • REQUEST_HEADER: Preserves the case of forwarded request headers.

  • RESPONSE_HEADER: Preserves the case of forwarded response headers.

  • BOTH_HEADER: Preserves the case of both request and response headers.

Verify the configuration

Deploy the client application

  1. Deploy the sleep pod to act as the client application.

    kubectl apply -f - <<EOF
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: sleep
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: sleep
      labels:
        app: sleep
        service: sleep
    spec:
      ports:
      - port: 80
        name: http
      selector:
        app: sleep
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: sleep
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: sleep
      template:
        metadata:
          labels:
            app: sleep
        spec:
          terminationGracePeriodSeconds: 0
          serviceAccountName: sleep
          containers:
          - name: sleep
            image: registry.cn-hangzhou.aliyuncs.com/acs/curl:8.1.2
            command: ["/bin/sleep", "infinity"]
            imagePullPolicy: IfNotPresent
            volumeMounts:
            - mountPath: /etc/sleep/tls
              name: secret-volume
          volumes:
          - name: secret-volume
            secret:
              secretName: sleep-secret
              optional: true
    ---
    EOF
  2. Check the running status of the client application.

    kubectl get pod | grep sleep

    Expected output:

    sleep-77cb457458-c9mds        2/2     Running   0          10s

Deploy the server application

  1. Deploy the httpbin-echo server application, which echoes the request headers in its response.

    kubectl apply -f - <<EOF
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: http-echo
      labels:
        app: http-echo
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: http-echo
      template:
        metadata:
          labels:
            app: http-echo
        spec:
          containers:
          - name: http-echo
            image: registry-cn-hangzhou.ack.aliyuncs.com/dev/http-echo:latest
            ports:
            - containerPort: 8080
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: http-echo
    spec:
      selector:
        app: http-echo
      ports:
        - protocol: TCP
          port: 80
          targetPort: 8080
          name: http
      type: ClusterIP
    EOF
  2. Check the running status of the server application.

    kubectl get pod | grep http-echo

    Expected output:

    http-echo-89d9b457f-pcctg     2/2     Running   0          20s

Verify request header case preservation

Send a request from the client to the server.

kubectl exec -it deploy/sleep -- curl http-echo -H 'X-TEST: test'

Expected output:

GET / HTTP/1.1
host: http-echo
user-agent: curl/8.1.2
accept: */*
x-test: test

As you can see, the x-test request header is converted to lowercase.

Verify response header case preservation

Send a request from the client to the server.

kubectl exec -it deploy/sleep -- curl http-echo -I

Expected output:

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
content-length: 476
x-envoy-upstream-service-time: 7
date: Tue, 19 Aug 2025 06:33:51 GMT
server: envoy

As you can see, Envoy converts the content-type and content-length response headers to lowercase.

Enable header case preservation

You can enable this feature by using the plugin or in the console. If you use the console, you must restart the applications for the change to take effect.

kubectl rollout restart deploy/http-echo deploy/sleep

Verify again

  1. Verify that request header case is preserved.

    kubectl exec -it deploy/sleep -- curl http-echo -H 'X-TEST: test'

    Expected output:

    GET / HTTP/1.1
    Host: http-echo
    User-Agent: curl/8.1.2
    Accept: */*
    X-TEST: test

    As you can see, the X-TEST request header remains in uppercase.

  2. Verify that response header case is preserved.

    kubectl exec -it deploy/sleep -- curl http-echo -I

    Expected output:

    HTTP/1.1 200 OK
    Content-Type: text/plain; charset=utf-8
    Content-Length: 476
    x-envoy-upstream-service-time: 1
    date: Tue, 19 Aug 2025 06:30:24 GMT
    server: envoy

    As you can see, the Content-Type and Content-Length headers in the response retain their original case.

Related information

To preserve the case of request and response headers on ASM instances running version 1.25 or later, update the mesh configuration as follows:

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Instance Information > Base Information.

  3. On the Config Info tab, in the Parameter configuration on the data plane section, click Edit next to Preserve request and response header case.

  4. In the Preserve request and response header case dialog box, turn on the switch and click OK.

    Important

    After you enable this feature, restart your applications to apply the change.