diff options
Diffstat (limited to 'nginx/t/js_internal_redirect.t')
-rw-r--r-- | nginx/t/js_internal_redirect.t | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/nginx/t/js_internal_redirect.t b/nginx/t/js_internal_redirect.t index abfe79f9..721113bb 100644 --- a/nginx/t/js_internal_redirect.t +++ b/nginx/t/js_internal_redirect.t @@ -11,6 +11,7 @@ use warnings; use strict; use Test::More; +use Socket qw/ CRLF /; BEGIN { use FindBin; chdir($FindBin::Bin); } @@ -54,6 +55,10 @@ http { return 200 redirect$arg_b; } + location /destroyed_ctx { + js_content test.destroyed_ctx; + } + location @named { return 200 named; } @@ -87,7 +92,16 @@ $t->write_file('test.js', <<EOF); } } - export default {njs:test_njs, redirect}; + function destroyed_ctx(r) { + try { + r.return(200); + + } catch (e) { + r.internalRedirect("\@sub"); + } + } + + export default {njs:test_njs, redirect, destroyed_ctx}; EOF @@ -103,5 +117,18 @@ like(http_get('/test?unsafe=1'), qr/500 Internal Server/s, 'unsafe redirect'); like(http_get('/test?quoted=1'), qr/200 .*redirect/s, 'quoted redirect'); +get('/destroyed_ctx', 'If-Match: tt'); ############################################################################### + +sub get { + my ($url, @headers) = @_; + return http( + "GET $url HTTP/1.1" . CRLF . + 'Host: localhost' . CRLF . + 'Connection: close' . CRLF . + join(CRLF, @headers) . CRLF . CRLF + ); +} + +################################################################################ |