[njs] HTTP: throwing an exception in internalRedirect() for a subrequest.

Alexander Borisov alexander.borisov at nginx.com
Thu Oct 8 15:48:24 UTC 2020


details:   https://hg.nginx.org/njs/rev/893fa730285c
branches:  
changeset: 1538:893fa730285c
user:      Alexander Borisov <alexander.borisov at nginx.com>
date:      Thu Oct 08 18:47:04 2020 +0300
description:
HTTP: throwing an exception in internalRedirect() for a subrequest.

This closes #214 issue on GitHub.

diffstat:

 nginx/ngx_http_js_module.c |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (15 lines):

diff -r 036a4fbf9204 -r 893fa730285c nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Tue Oct 06 20:51:56 2020 +0300
+++ b/nginx/ngx_http_js_module.c	Thu Oct 08 18:47:04 2020 +0300
@@ -1831,6 +1831,11 @@ ngx_http_js_ext_internal_redirect(njs_vm
         return NJS_ERROR;
     }
 
+    if (r->parent != NULL) {
+        njs_vm_error(vm, "internalRedirect cannot be called from a subrequest");
+        return NJS_ERROR;
+    }
+
     ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
 
     if (ngx_http_js_string(vm, njs_arg(args, nargs, 1), &uri) != NJS_OK) {


More information about the nginx-devel mailing list