openresty / openresty/lua-nginx-module

Feature request: `ngx.req.get_header` to get a single header value

Open
#2,042 3 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.