Skip to content

Commit 7d92e90

Browse files
committed
added tests for the fix in commit 2297eed.
1 parent a851e05 commit 7d92e90

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

t/re-sub.t

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use Cwd qw(cwd);
99

1010
repeat_each(2);
1111

12-
plan tests => repeat_each() * (blocks() * 4 + 6);
12+
plan tests => repeat_each() * (blocks() * 4 + 8);
1313

1414
my $pwd = cwd();
1515

@@ -205,3 +205,75 @@ GET /re
205205
[error]
206206
bad argument type
207207
208+
209+
210+
=== TEST 6: ngx.re.gsub: use of ngx.req.get_headers in the user callback
211+
--- http_config eval: $::HttpConfig
212+
--- config
213+
214+
location = /t {
215+
content_by_lua '
216+
local data = [[
217+
INNER
218+
INNER
219+
]]
220+
221+
-- ngx.say(data)
222+
223+
local res = ngx.re.gsub(data, "INNER", function(inner_matches)
224+
local header = ngx.req.get_headers()["Host"]
225+
-- local header = ngx.var["http_HEADER"]
226+
return "INNER_REPLACED"
227+
end, "s")
228+
229+
ngx.print(res)
230+
';
231+
}
232+
233+
--- request
234+
GET /t
235+
--- response_body
236+
INNER_REPLACED
237+
INNER_REPLACED
238+
239+
--- no_error_log
240+
[error]
241+
bad argument type
242+
NYI
243+
244+
245+
246+
=== TEST 7: ngx.re.gsub: use of ngx.var in the user callback
247+
--- http_config eval: $::HttpConfig
248+
--- config
249+
250+
location = /t {
251+
content_by_lua '
252+
local data = [[
253+
INNER
254+
INNER
255+
]]
256+
257+
-- ngx.say(data)
258+
259+
local res = ngx.re.gsub(data, "INNER", function(inner_matches)
260+
-- local header = ngx.req.get_headers()["Host"]
261+
local header = ngx.var["http_HEADER"]
262+
return "INNER_REPLACED"
263+
end, "s")
264+
265+
ngx.print(res)
266+
';
267+
}
268+
269+
--- request
270+
GET /t
271+
--- response_body
272+
INNER_REPLACED
273+
INNER_REPLACED
274+
275+
--- no_error_log
276+
[error]
277+
bad argument type
278+
NYI
279+

0 commit comments

Comments
 (0)