You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
kong.request.get_header will call openresty api
ngx.req.get_headers
, which every time it called, it created a lua table, and copy all key and value into the table, which cause all headers copy from c land to lua land.
Also, By default, ngx.req.get_headers copy 100 headers, so, it will not work as expect if size of request headers is great than 100.
so, why not kong implement kong.request.get_header by use
$http_header
variables?
And
https://github.com/openresty/lua-nginx-module#ngxreqget_headers
says:
why kong implement kong.request.get_header by use $http_header variables?
Thank you this is a good suggestion and we will consider it (feel free to open a pull request to change it!).
If we don't do this, at least we should consider putting a warning in
kong.request.get_header
's docs.
Also, By default, ngx.req.get_headers copy 100 headers, so, it will not work as expect if size of request headers is great than 100.
The function signature is
kong.request.get_headers([max_headers])
. The function
documentation
specifies what
max_headers
means cleanly. If someone expects more headers than that, they are trying to use the function without reading the docs first. I don't know what else we can do here.
why kong implement kong.request.get_header by use $http_header variables?
Thank you this is a good suggestion and we will consider it (feel free to open a pull request to change it!).
If we don't do this, at least we should consider putting a warning in
kong.request.get_header
's docs.
Also, By default, ngx.req.get_headers copy 100 headers, so, it will not work as expect if size of request headers is great than 100.
The function signature is
kong.request.get_headers([max_headers])
. The function
documentation
specifies what
max_headers
means cleanly. If someone expects more headers than that, they are trying to use the function without reading the docs first. I don't know what else we can do here.
Sorry, actually what I mean is the implementation of kong.request.get_header(name) call _REQUEST.get_headers without pass max_headers, so by default 100 is used. If the size of request header exceed 100, the header we want retrieve may not in the return table.
function _REQUEST.get_header(name)
check_phase(PHASES.request)
if type(name) ~= "string" then
error("header name must be a string", 2)
-- the header specify by the `name` may not in the table, since only 100 headers return by _REQUEST.get_headers()
local header_value = _REQUEST.get_headers()[name]
if type(header_value) == "table" then
return header_value[1]
return header_value