[PATCH] Tests: added tests for named captures with v->set_handler
Maxim Dounin
mdounin at mdounin.ru
Wed Jun 3 15:55:49 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1780502078 -10800
# Wed Jun 03 18:54:38 2026 +0300
# Node ID 00e132c32aae2f22581bdfffb5db846f99d13c71
# Parent 57f8b3db13319b6f1977e825a72689e76e7d7e2e
Tests: added tests for named captures with v->set_handler.
diff --git a/rewrite_named_captures.t b/rewrite_named_captures.t
--- a/rewrite_named_captures.t
+++ b/rewrite_named_captures.t
@@ -22,7 +22,7 @@ use Test::Nginx;
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(6)
+my $t = Test::Nginx->new()->has(qw/http rewrite map/)->plan(7)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -69,6 +69,17 @@ http {
rewrite ^(?<arg_foo>.*) /;
return 200 "value: $arg_foo\n";
}
+
+ location /set_args {
+ if ($arg_foo ~ "(?<args>.*)") {}
+ proxy_pass http://127.0.0.1:8081;
+ }
+ }
+
+ server {
+ listen 127.0.0.1:8081;
+ server_name localhost;
+ return 200 "value: $args";
}
map $uri $late {
@@ -110,4 +121,15 @@ like(http_get('/prefix?foo=arg'), qr!val
like(http_get('/prefix/rewrite?foo=arg'), qr!value: /prefix/rewrite!,
'value from capture overrides arg');
+# when a named capture changes a variable with v->set_handler, notably $args
+# or $limit_rate, the handler should be called
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.3');
+
+like(http_get('/set_args?foo=arg'), qr!value: arg!,
+ 'variable with set_handler');
+
+}
+
###############################################################################
More information about the nginx-devel
mailing list