apisix-java-plugin-runner icon indicating copy to clipboard operation
apisix-java-plugin-runner copied to clipboard

bug: content-type reset to text / plain after the postFilter stage

Open rrennaloiacono opened this issue 3 years ago • 2 comments

When implementing the postFilter stage, the postResponse.setHeader ("content-type", "some value") method is not taken into account. The content-type returned to the client is always "text / plain". The problem concerns only and exclusively this header. For others it works.

rrennaloiacono avatar Aug 30 '22 12:08 rrennaloiacono

My use case is following: I have an api that returns content in xml or json depending on request header "accept". On this api I need to implement a postFilter even to do some operations. So I pour all upstream headers into postResponse. But, although the response body is formatted correctly, the content type is not the correct one. But it's text / plain.

rrennaloiacono avatar Aug 30 '22 12:08 rrennaloiacono

some response headers can not be changed, ref: https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua#L70-L81

local exclude_resp_header = {
    ["connection"] = true,
    ["content-length"] = true,
    ["transfer-encoding"] = true,
    ["location"] = true,
    ["server"] = true,
    ["www-authenticate"] = true,
    ["content-encoding"] = true,
    ["content-type"] = true,
    ["content-location"] = true,
    ["content-language"] = true,
}

tzssangglass avatar Aug 31 '22 02:08 tzssangglass