File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ local get_string_buf = base.get_string_buf
2020local get_size_ptr = base .get_size_ptr
2121local setmetatable = setmetatable
2222local lower = string.lower
23+ local find = string.find
2324local rawget = rawget
2425local ngx = ngx
2526local get_request = base .get_request
@@ -114,7 +115,12 @@ local truncated = ffi.new("int[1]")
114115
115116local req_headers_mt = {
116117 __index = function (tb , key )
117- return rawget (tb , (str_replace_char (lower (key ), ' _' , ' -' )))
118+ key = lower (key )
119+ local value = rawget (tb , key )
120+ if value == nil and find (key , ' _' , 1 , true ) then
121+ value = rawget (tb , (str_replace_char (key , ' _' , ' -' )))
122+ end
123+ return value
118124 end
119125}
120126
Original file line number Diff line number Diff line change @@ -140,6 +140,8 @@ qr/\[TRACE\s+\d+ content_by_lua\(nginx\.conf:\d+\):4 loop\]/
140140
141141
142142=== TEST 4 : ngx. req. get_headers (metatable)
143+ -- - http_config
144+ underscores_in_headers on;
143145-- - config
144146 location = /t {
145147 set $ foo hello;
@@ -159,6 +161,10 @@ qr/\[TRACE\s+\d+ content_by_lua\(nginx\.conf:\d+\):4 loop\]/
159161 for _, k in ipairs(keys ) do
160162 ngx. say (k, " : " , headers[k])
161163 end
164+
165+ ngx. say (" X_Bar_Header: " , headers[" X_Bar_Header" ])
166+ ngx. say (" x_Bar_Header: " , headers[" x_Bar_Header" ])
167+ ngx. say (" x_bar_header: " , headers[" x_bar_header" ])
162168 }
163169 }
164170--- request
@@ -169,9 +175,14 @@ baz: baz
169175connection: close
170176foo-bar: foo
171177host: localhost
178+ x_bar_header: bar
179+ X_Bar_Header: bar
180+ x_Bar_Header: bar
181+ x_bar_header: bar
172182-- - more_headers
173183Foo-Bar: foo
174184Baz: baz
185+ X_Bar_Header: bar
175186-- - wait : 0.2
176187-- - error_log eval
177188qr/ \[TRACE\s+ \d+ .*? -> \d+ \]/
You can’t perform that action at this time.
0 commit comments