]> git.kaiwu.me - njs.git/commitdiff
HTTP: fixed r.subrequest() check for nested subrequests.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 18 Sep 2024 02:17:09 +0000 (19:17 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Wed, 18 Sep 2024 04:52:27 +0000 (21:52 -0700)
The issue was introduced in a14be61c86 (0.8.5).

This fixes #783 on Github.

nginx/ngx_http_js_module.c

index 4a50a9494a482381427109a638d128b36759e6c2..dec651982d4afac37bb30c0a71168d6da9ac3919 100644 (file)
@@ -3358,7 +3358,7 @@ ngx_http_js_ext_subrequest(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
 
     ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
 
-    if (r->main != r) {
+    if (r->subrequest_in_memory) {
         njs_vm_error(vm, "subrequest can only be created for "
                          "the primary request");
         return NJS_ERROR;
@@ -5722,7 +5722,7 @@ ngx_http_qjs_ext_subrequest(JSContext *cx, JSValueConst this_val,
 
     ctx = ngx_http_get_module_ctx(r, ngx_http_js_module);
 
-    if (r->main != r) {
+    if (r->subrequest_in_memory) {
         return JS_ThrowTypeError(cx, "subrequest can only be created for "
                                      "the primary request");
     }