-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(var): patch set_header #97
Conversation
patch the `req.set_header` function to invalidate the relevant `variable_index` entry for the modified header. Specifically, after normalizing the header name, the corresponding `variable_index` entry is set to `nil`. This ensures that subsequent accesses to `ngx.var.http_*` variables will bypass the cached index and fetch the updated header value. same fix way as: #59 Fix: [KAG-5963](https://konghq.atlassian.net/browse/KAG-5963) Signed-off-by: tzssangglass <[email protected]>
lualib/resty/kong/var.lua
Outdated
local orig_set_header = req.set_header | ||
|
||
req.set_header = function(...) | ||
local normalized_header = replace_dashes_lower(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps I need to unpack the data structure(…) and retrieve the first element; this should be clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, doesn't the current implementation mean we're passing both header_name
and header_value
from ngx.req.set_header(header_name, header_value)
, to replace_dashes_lower
?
We can probably patch this set_header
function with a function that takes exactly 2 arguments, then use the first (header_name) to invalidate the index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to
req.set_header = function(name, value)
local normalized_header = replace_dashes_lower(name)
I did not choose the
req.set_header = function(...)
local args = table.unpack(...)
local normalized_header = replace_dashes_lower(args[1])
I feel that this will degrade performance.
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
patch the
req.set_header
function to invalidate the relevantvariable_index
entry for the modified header. Specifically, after normalizing the header name, the correspondingvariable_index
entry is set tonil
. This ensures that subsequent accesses tongx.var.http_*
variables will bypass the cached index and fetch the updated header value.same fix way as: #59
Fix: KAG-5963
Fix: FTI-6406