From: Dmitry Volyntsev Date: Thu, 13 Jun 2024 06:31:08 +0000 (-0700) Subject: HTTP: simplified check for subrequest from a subrequest. X-Git-Tag: 0.8.6~49 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=a14be61c86db926c93645e929a79a960674b7715;p=njs.git HTTP: simplified check for subrequest from a subrequest. --- diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 5c8c0480..260cd497 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -3153,7 +3153,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 (ctx->vm != vm) { + if (r->main != r) { njs_vm_error(vm, "subrequest can only be created for " "the primary request"); return NJS_ERROR; @@ -3511,7 +3511,7 @@ ngx_http_js_ext_get_parent(njs_vm_t *vm, njs_object_prop_t *prop, ctx = r->parent ? ngx_http_get_module_ctx(r->parent, ngx_http_js_module) : NULL; - if (ctx == NULL || ctx->vm != vm) { + if (ctx == NULL) { njs_value_undefined_set(retval); return NJS_DECLINED; } diff --git a/nginx/t/js_subrequests.t b/nginx/t/js_subrequests.t index f1937c9c..4a58d6f3 100644 --- a/nginx/t/js_subrequests.t +++ b/nginx/t/js_subrequests.t @@ -590,6 +590,9 @@ local $TODO = 'not yet' unless has_version('0.8.5'); http_get('/sr_error_in_callback'); +ok(index($t->read_file('error.log'), 'subrequest can only be created for') > 0, + 'subrequest creation failed'); + } $t->stop(); @@ -602,8 +605,6 @@ ok(index($t->read_file('error.log'), 'failed to convert options.args') > 0, 'subrequest invalid args exception'); ok(index($t->read_file('error.log'), 'too big subrequest response') > 0, 'subrequest too large body'); -ok(index($t->read_file('error.log'), 'subrequest creation failed') > 0, - 'subrequest creation failed'); ok(index($t->read_file('error.log'), 'js subrequest: failed to get the parent context') > 0, 'zero parent ctx');