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


##########
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:
   This is the feature of current PR. `header(ctx, header_name)` method maybe 
get wrong values from ctx cache if the `add_header` method does not invalidate 
the cache.



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