Feature request: `ngx.req.get_header` to get a single header value
It would be useful if such an API is provided.
Currently, people uses ngx.req.get_headers()[key] to get header value for key. This is of low efficiency. If we try to cache the result of get_headers(), we need to update the cache every time headers are changed(and it will be impractical if other modules may change headers).
Even the most trivial implementation(brute force search) could have a better performance than the ngx.req.get_headers()[key] solution. And for most cases, the header should be pre-hashed.
Is there any reason we do not add the API? Thank you.
https://www.nginx.com/resources/wiki/start/topics/examples/headers_management/
Note that the ngx.var.HEADER API call, which uses core $http_HEADER variables, may be more preferable for reading individual request headers.
Note that the ngx.var.HEADER API call, which uses core $http_HEADER variables, may be more preferable for reading individual request headers.
Yes, it solves some of the problems. But $http_HEADER does not have a limitation on headers to search, which behaves differently from ngx.req.get_headers. That may be important in some cases.