You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org> on 2023/02/20 06:16:49 UTC
[GitHub] [apisix] monkeyDluffy6017 commented on a diff in pull request #8824: fix: invalidate cache in core.request.add_haeder and fix some calls
monkeyDluffy6017 commented on code in PR #8824:
URL: https://github.com/apache/apisix/pull/8824#discussion_r1111496828
##########
apisix/core/request.lua:
##########
@@ -143,14 +143,28 @@ function _M.set_header(ctx, header_name, header_value)
end
end
-function _M.add_header(header_name, header_value)
+function _M.add_header(ctx, header_name, header_value)
+ if type(ctx) == "string" then
+ header_value = header_name
+ header_name = ctx
+ ctx = nil
+
+ log.warn("DEPRECATED: use add_header(ctx, header_name, header_value) instead")
+ end
+
local err
header_name, err = _validate_header_name(header_name)
if err then
error(err)
end
req_add_header(header_name, header_value)
+
+ if not ctx then
+ ctx = ngx.ctx.api_ctx
+ end
+
+ ctx.headers = {}
Review Comment:
The invalidate cache operatio should follow the `set_header` function
##########
apisix/core/request.lua:
##########
@@ -143,14 +143,28 @@ function _M.set_header(ctx, header_name, header_value)
end
end
-function _M.add_header(header_name, header_value)
+function _M.add_header(ctx, header_name, header_value)
+ if type(ctx) == "string" then
+ header_value = header_name
+ header_name = ctx
+ ctx = nil
+
+ log.warn("DEPRECATED: use add_header(ctx, header_name, header_value) instead")
+ end
+
local err
header_name, err = _validate_header_name(header_name)
if err then
error(err)
end
req_add_header(header_name, header_value)
+
+ if not ctx then
+ ctx = ngx.ctx.api_ctx
+ end
+
+ ctx.headers = {}
Review Comment:
The invalidate cache operation should follow the `set_header` function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org