Skip to content

bug: response-rewrite filters.regex does not apply when content-encoding: gzip #10562

Description

@JoonaHa

Current Behavior

I have an APISIX route that uses proxy-rewrite to proxy users to specific endpoint. The endpoint response is a JSON payload with content headers Content-Type: application/json and content-encoding: gzip.

When I add response-rewrite plugin with filters.regex APISIX drops the content-encoding: gzip header. When I add the header back manually using response-rewrite's headers.add functionality, the filters.regex replacement is not applied.

Here is my route configuration with placeholder urls:

{
    "id":"testroute",
    "methods":[
        "GET"
    ],
    "plugins":{
        "proxy-rewrite":{
            "uri":"/specific/path",
            "host":"example.org"
        },
        "response-rewrite":{
            "headers":{
                "add":[
                    "content-encoding: gzip"
                ]
            },
            "filters":[
                {
                    "regex":"conformsTo",
                    "scope":"global",
                    "replace":"replacedvalue"
                }
            ],
            "vars":[
                [
                    "status",
                    "==",
                    200
                ]
            ]
        }
    },
    "upstream":{
        "type":"roundrobin",
        "scheme":"https",
        "nodes":{
            "example.org:443":1
        }
    },
    "uri":"/testroute"
}

Expected Behavior

Upstream's content-encoding: gzip header is passed normally trough APISIX and response-rewrite's filters.regex is applied to the response JSON.

Error Logs

No response

Steps to Reproduce

  1. Have an endpoint which responds with headers: Content-Type: application/json and content-encoding: gzip
  2. Make a APISIX route with proxy-rewrite and response-rewrite
  3. See if response-rewrite is applied with correct encoding headers.

Environment

APISIX Docker image apache/apisix:3.7.0-debian

Metadata

Metadata

Assignees

Type

No type

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions