diff --git a/spec/unit/features/descriptor.feature b/spec/unit/features/descriptor.feature index c226a86..e2904dc 100644 --- a/spec/unit/features/descriptor.feature +++ b/spec/unit/features/descriptor.feature @@ -44,6 +44,10 @@ Feature: Descriptor extraction and claim resolution Scenario: AC-7b header limit_key with hyphens matches OpenResty normalized key with underscores Given limit_keys is "header:x-e2e-key" And header "x_e2e_key" is "exhaust-abc123" + + Scenario: AC-7c uppercase header limit_key matches OpenResty normalized key (lowercase + underscore) + Given limit_keys is "header:X-E2E-Key" + And header "x_e2e_key" is "exhaust-abc123" When I extract descriptors Then descriptor "header:x-e2e-key" is "exhaust-abc123" And missing keys are empty diff --git a/src/fairvisor/descriptor.lua b/src/fairvisor/descriptor.lua index 38ca43c..f99019f 100644 --- a/src/fairvisor/descriptor.lua +++ b/src/fairvisor/descriptor.lua @@ -249,9 +249,9 @@ function _M.extract(limit_keys, request_context) value = headers[name] if value == nil then -- OpenResty normalizes header names: lowercase and hyphen to underscore (e.g. X-E2E-Key -> x_e2e_key). - local name_underscore = string_gsub(name, "-", "_") - local name_lower = string_lower(name) - value = headers[name_underscore] or headers[name_lower] + -- Use _normalize_header_name so both transformations are applied together; the two-step + -- approach (hyphen→underscore OR lowercase separately) misses uppercase+hyphenated keys. + value = headers[_normalize_header_name(name)] end if value == nil then local name_norm = _normalize_header_name(name)