Skip to content
Browse files

added a test for using ngx_eval in named locations. this exposes an i…

…ssue in the nginx core, reported by drdrxp in github issue #1.
  • Loading branch information...
1 parent d57d814 commit 4eb2a024a0ef312f714916f4e7c07b6ed1ef9c71 @agentzh agentzh committed
Showing with 84 additions and 1 deletion.
  1. +2 −1 .gitignore
  2. +6 −0 ngx_http_eval_module.c
  3. +76 −0 t/bug.t
View
3 .gitignore
@@ -31,10 +31,11 @@ misc/chunked
ctags
src/module.c
releng
-t
*.html
all.sh
build10
buildroot/
go
work/
+t/servroot/
+build12
View
6 ngx_http_eval_module.c
@@ -353,6 +353,12 @@ ngx_http_eval_post_subrequest_handler(ngx_http_request_t *r, void *data, ngx_int
/* dd("rc == %d", rc); */
ctx->status = rc;
+#if 0
+ /* work-around a bug in the nginx core (ngx_http_named_location)
+ */
+ r->parent->write_event_handler = ngx_http_core_run_phases;
+#endif
+
return NGX_OK;
}
View
76 t/bug.t
@@ -0,0 +1,76 @@
+# vi:filetype=
+
+use lib 'lib';
+use Test::Nginx::Socket; # skip_all => 'ngx_memc storage commands do not work with the ngx_eval module';
+
+repeat_each(2);
+
+plan tests => repeat_each() * 2 * blocks();
+
+$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
+
+no_long_string();
+#no_diff;
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: bug
+--- config
+ location = /eval {
+ eval_escalate on;
+ eval $var {
+ set $foo bar;
+ return 403;
+ }
+ return 405;
+ }
+--- request
+ GET /eval
+--- response_body_like: 403 Forbidden
+--- error_code: 403
+
+
+
+=== TEST 2: bug
+--- SKIP
+--- config
+location /eval/ {
+ rewrite /eval(.*)$ $1 break;
+ eval $res {
+ set $memc_key $host:$request_uri;
+ set $memc_value 1;
+ set $memc_cmd incr;
+ memc_pass 127.0.0.1:11211;
+ }
+ resolver 10.40.6.72;
+ proxy_pass http://www.yahoo.com/;
+ }
+--- request
+ GET /eval
+--- response_body
+
+
+
+=== TEST 3: github issue #1: "eval" hangs in named locations.
+--- config
+ location @eval {
+ eval $var {
+ proxy_pass http://127.0.0.1:$server_port/echo;
+ }
+ echo $var;
+ }
+
+ location /echo {
+ echo hello;
+ }
+
+ location /t {
+ echo_exec @eval;
+ }
+--- request
+ GET /t
+--- response_body
+hello
+

0 comments on commit 4eb2a02

Please sign in to comment.
Something went wrong with that request. Please try again.