Skip to content

bug: after using core.request.set_header to set the header, ctx.var still caches the old value #11325

Description

@AlinsRan

Current Behavior

  1. send a request with header xtag: b
 curl http://127.0.0.1:9080/get -H "xtag: b"
  1. accessing and updating header xtag in apisix.

After the update, when accessing the HTTP header xtag through ctx.var, it was expected to receive a but received b

-- get: b
core.log.info("ctx.var.http_xtag: ", ctx.var.http_xtag)  

-- set header,  xtag = a
core.request.set_header(ctx, "xtag", "a")

-- get: b
-- expect: a
core.log.info("ctx.var.http_xtag: ", ctx.var.http_xtag)  

As shown in the above example, when using ctx.var to retrieve the HTTP header, once the value is cached, it will no longer be updated.

Expected Behavior

When updating the HTTP header, the ctx.var cache will also be updated.

Environment

  • APISIX version (run apisix version): 3.9.0
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions