jiangfucheng commented on code in PR #8824:
URL: https://github.com/apache/apisix/pull/8824#discussion_r1113757464
##########
apisix/core/request.lua:
##########
@@ -143,14 +143,35 @@ 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
+ local changed = false
+ if is_apisix_or then
+ changed = a6_request.is_request_header_set()
+ end
+
+
req_add_header(header_name, header_value)
+
+ if is_apisix_or and not changed then
+ a6_request.clear_request_header()
+ if ctx and ctx.headers then
+ ctx.headers[header_name] = header_value
Review Comment:
Fixed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]