jiangfucheng commented on code in PR #8824:
URL: https://github.com/apache/apisix/pull/8824#discussion_r1106569843


##########
t/core/request.t:
##########
@@ -439,3 +439,59 @@ while ($i <= 101) {
 $s
 --- response_body
 101
+
+
+
+=== TEST 15: add header
+--- config
+    location /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            ngx.ctx.api_ctx = {}
+            local ctx = ngx.ctx.api_ctx
+            core.request.add_header(ctx, "test_header", "test")
+            local h = core.request.header(ctx, "test_header")
+            ngx.say(h)
+        }
+    }
+--- response_body
+test
+
+
+
+=== TEST 16: test invalidated cache for add_header
+--- config
+    location /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            ngx.ctx.api_ctx = {}
+            local ctx = ngx.ctx.api_ctx
+            core.request.add_header(ctx, "test_header", "test")
+            local h = core.request.header(ctx, "test_header")
+            ngx.say(ctx.headers.test_header)
+            core.request.add_header(ctx, "test_header", "abc")
+            ngx.say(ctx.headers.test_header)
+        }
+    }
+--- response_body
+test
+nil

Review Comment:
   `add_header()` method will invalidate cache in `ctx`, `header()` method will 
add cache to `ctx`, so first value is "test" and the second value is "nil"



-- 
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