openresty / openresty/lua-nginx-module
Feature request: `ngx.req.get_header` to get a single header value
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing ngx.req.get_headers API and the three comments on this issue. Determine the intended single-header lookup behavior and where the current API is implemented; done means a new ngx.req.get_header API with suitable coverage and documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100