Skip to content

Commit

Permalink
HTTP: improved r.parent property handler.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xeioex committed Nov 25, 2019
1 parent 2116fe3 commit 0fa4360
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nginx/ngx_http_js_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 0fa4360

Please sign in to comment.