You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2021/11/14 07:09:04 UTC
[apisix] branch master updated: fix: response.set_header can remove header like request.set_header (#5499)
This is an automated email from the ASF dual-hosted git repository.
membphis 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 6c5108f fix: response.set_header can remove header like request.set_header (#5499)
6c5108f is described below
commit 6c5108ff3896b96e1bf0a0a68fd2e7a9aadc1162
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Sun Nov 14 15:08:55 2021 +0800
fix: response.set_header can remove header like request.set_header (#5499)
Signed-off-by: spacewander <sp...@gmail.com>
---
apisix/core/response.lua | 4 +++-
t/core/response.t | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/apisix/core/response.lua b/apisix/core/response.lua
index e1f0f4d..9ce9c40 100644
--- a/apisix/core/response.lua
+++ b/apisix/core/response.lua
@@ -101,7 +101,9 @@ local function set_header(append, ...)
if count == 1 then
local headers = select(1, ...)
if type(headers) ~= "table" then
- error("should be a table if only one argument", 2)
+ -- response.set_header(name, nil)
+ ngx_header[headers] = nil
+ return
end
for k, v in pairs(headers) do
diff --git a/t/core/response.t b/t/core/response.t
index eb8eda8..ed7856b 100644
--- a/t/core/response.t
+++ b/t/core/response.t
@@ -142,3 +142,24 @@ aaa: bbb, bbb
ccc: ddd
--- no_error_log
[error]
+
+
+
+=== TEST 7: delete header
+--- config
+ location = /t {
+ access_by_lua_block {
+ local core = require("apisix.core")
+ core.response.set_header("aaa", "bbb")
+ core.response.set_header("aaa", nil)
+ core.response.exit(200, "done\n")
+ }
+ }
+--- request
+GET /t
+--- response_body
+done
+--- response_headers
+aaa:
+--- no_error_log
+[error]