[njs] HTTP: returning undefined value when "responseBody" is unavailable.

Dmitry Volyntsev xeioex at nginx.com
Fri Mar 20 14:56:43 UTC 2020


details:   https://hg.nginx.org/njs/rev/83c9c195a8e2
branches:  
changeset: 1359:83c9c195a8e2
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Mar 20 17:33:10 2020 +0300
description:
HTTP: returning undefined value when "responseBody" is unavailable.

Missed in b758915e2406.

diffstat:

 nginx/ngx_http_js_module.c |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (17 lines):

diff -r 573d264cb7e7 -r 83c9c195a8e2 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Fri Mar 20 17:33:06 2020 +0300
+++ b/nginx/ngx_http_js_module.c	Fri Mar 20 17:33:10 2020 +0300
@@ -2196,7 +2196,12 @@ ngx_http_js_ext_get_response_body(njs_vm
 
     b = r->out ? r->out->buf : NULL;
 
-    len = b ? b->last - b->pos : 0;
+    if (b == NULL) {
+        njs_value_undefined_set(retval);
+        return NJS_OK;
+    }
+
+    len = b->last - b->pos;
 
     p = njs_vm_value_string_alloc(vm, retval, len);
     if (p == NULL) {


More information about the nginx-devel mailing list