From: Dmitry Volyntsev Date: Mon, 25 Nov 2019 14:54:58 +0000 (+0300) Subject: HTTP: improved r.parent property handler. X-Git-Tag: 0.3.8~52 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=0fa4360a5965b66a9055d3b0cd1170faa758365e;p=njs.git 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. --- 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));