You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2023/01/06 03:57:04 UTC

[apisix] branch master updated: fix(ext-plugin-post-resp): can't set content-type response header (#8588)

This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 91122f9e9 fix(ext-plugin-post-resp): can't set content-type response header (#8588)
91122f9e9 is described below

commit 91122f9e9bf12f352c103b74df3b60d7f6223841
Author: soulbird <zh...@outlook.com>
AuthorDate: Fri Jan 6 11:56:57 2023 +0800

    fix(ext-plugin-post-resp): can't set content-type response header (#8588)
    
    Co-authored-by: soulbird <zh...@gmail.com>
    Fixes https://github.com/apache/apisix/issues/8388
---
 apisix/plugins/ext-plugin/init.lua | 12 +++++-------
 t/lib/ext-plugin.lua               |  2 ++
 t/plugin/ext-plugin/response.t     |  1 +
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/apisix/plugins/ext-plugin/init.lua b/apisix/plugins/ext-plugin/init.lua
index 0f9e0de14..b6fcf6fea 100644
--- a/apisix/plugins/ext-plugin/init.lua
+++ b/apisix/plugins/ext-plugin/init.lua
@@ -791,13 +791,11 @@ local rpc_handlers = {
             for i = 1, len do
                 local entry = call_resp:Headers(i)
                 local name = str_lower(entry:Name())
-                if not exclude_resp_header[name] then
-                    if resp_headers[name] == nil then
-                        core.response.set_header(name, entry:Value())
-                        resp_headers[name] = true
-                    else
-                        core.response.add_header(name, entry:Value())
-                    end
+                if resp_headers[name] == nil then
+                    core.response.set_header(name, entry:Value())
+                    resp_headers[name] = true
+                else
+                    core.response.add_header(name, entry:Value())
                 end
             end
         else
diff --git a/t/lib/ext-plugin.lua b/t/lib/ext-plugin.lua
index 6403e74f5..b19a79838 100644
--- a/t/lib/ext-plugin.lua
+++ b/t/lib/ext-plugin.lua
@@ -534,6 +534,8 @@ function _M.go(case)
                 if runner and runner == "Go-runner" then
                     headers["x-runner"] = "Test-Runner"
                 end
+
+                headers["Content-Type"] = "application/json"
             end
 
             local i = 1
diff --git a/t/plugin/ext-plugin/response.t b/t/plugin/ext-plugin/response.t
index 2500e5db0..d8a2be2a5 100644
--- a/t/plugin/ext-plugin/response.t
+++ b/t/plugin/ext-plugin/response.t
@@ -155,6 +155,7 @@ resp-X-Runner: Go-runner
 --- error_code: 200
 --- response_headers
 X-Runner: Test-Runner
+Content-Type: application/json
 --- response_body
 hello world