From 0fa4360a5965b66a9055d3b0cd1170faa758365e Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Mon, 25 Nov 2019 17:54:58 +0300 Subject: [PATCH] HTTP: improved r.parent property handler. Previously, r.parent handler threw an exception if it was called not for a subrequest. This is too restrictive, as it prevents any iterations over all r properties (for example: JSON.stringify()). Instead, "undefined" value is returned as it is already done for r.requestBody when request body is unavailable. --- nginx/ngx_http_js_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index e1ee56c0..340887d0 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -2091,8 +2091,8 @@ ngx_http_js_ext_get_parent(njs_vm_t *vm, njs_value_t *value, void *obj, : NULL; if (ctx == NULL || ctx->vm != vm) { - njs_vm_error(vm, "parent can only be returned for a subrequest"); - return NJS_ERROR; + njs_value_undefined_set(value); + return NJS_OK; } njs_value_assign(value, njs_value_arg(&ctx->request)); -- 2.47.3