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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to