diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2019-03-26 14:51:03 +0300 |
---|---|---|
committer | Dmitry Volyntsev <xeioex@nginx.com> | 2019-03-26 14:51:03 +0300 |
commit | d2074d852c1b9019c447709b0f8cc04392662c2c (patch) | |
tree | 584940c3d4a73a29b56529e5ab9c379da541c01c /nginx/ngx_http_js_module.c | |
parent | 8a7216de8a204fc76e68da23fa5c2e58586e14a6 (diff) | |
download | njs-d2074d852c1b9019c447709b0f8cc04392662c2c.tar.gz njs-d2074d852c1b9019c447709b0f8cc04392662c2c.zip |
Modules: returning undefined value for absent values.
Instead of empty string.
Diffstat (limited to 'nginx/ngx_http_js_module.c')
-rw-r--r-- | nginx/ngx_http_js_module.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 3599c9ef..8c3486e5 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -922,7 +922,8 @@ ngx_http_js_ext_get_header_out(njs_vm_t *vm, njs_value_t *value, void *obj, h = ngx_http_js_get_header(&r->headers_out.headers.part, v->start, v->length); if (h == NULL) { - return njs_vm_value_string_set(vm, value, NULL, 0); + njs_value_undefined_set(value); + return NJS_OK; } return njs_vm_value_string_set(vm, value, h->value.data, h->value.len); @@ -1433,8 +1434,8 @@ ngx_http_js_ext_get_request_body(njs_vm_t *vm, njs_value_t *value, void *obj, } if (r->request_body == NULL || r->request_body->bufs == NULL) { - njs_vm_error(vm, "request body is unavailable"); - return NJS_ERROR; + njs_value_undefined_set(value); + return NJS_OK; } if (r->request_body->temp_file) { @@ -1502,7 +1503,8 @@ ngx_http_js_ext_get_header_in(njs_vm_t *vm, njs_value_t *value, void *obj, h = ngx_http_js_get_header(&r->headers_in.headers.part, v->start, v->length); if (h == NULL) { - return njs_vm_value_string_set(vm, value, NULL, 0); + njs_value_undefined_set(value); + return NJS_OK; } return njs_vm_value_string_set(vm, value, h->value.data, h->value.len); @@ -1531,7 +1533,9 @@ ngx_http_js_ext_get_arg(njs_vm_t *vm, njs_value_t *value, void *obj, return njs_vm_value_string_set(vm, value, arg.data, arg.len); } - return njs_vm_value_string_set(vm, value, NULL, 0); + njs_value_undefined_set(value); + + return NJS_OK; } @@ -1620,7 +1624,8 @@ ngx_http_js_ext_get_variable(njs_vm_t *vm, njs_value_t *value, void *obj, vv = ngx_http_get_variable(r, &name, key); if (vv == NULL || vv->not_found) { - return njs_vm_value_string_set(vm, value, NULL, 0); + njs_value_undefined_set(value); + return NJS_OK; } return njs_vm_value_string_set(vm, value, vv->data, vv->len); |