[njs] HTTP: returing undefined for Content-Type when the header is absent.
Dmitry Volyntsev
xeioex at nginx.com
Wed Jun 8 17:13:12 UTC 2022
details: https://hg.nginx.org/njs/rev/cf267407eabe
branches:
changeset: 1879:cf267407eabe
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Tue Jun 07 21:30:57 2022 -0700
description:
HTTP: returing undefined for Content-Type when the header is absent.
This unifies empty response value type for r.headersOut.
diffstat:
nginx/ngx_http_js_module.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diffs (29 lines):
diff -r 6ef77c24c924 -r cf267407eabe nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Mon Jun 06 23:27:11 2022 -0700
+++ b/nginx/ngx_http_js_module.c Tue Jun 07 21:30:57 2022 -0700
@@ -1978,6 +1978,12 @@ ngx_http_js_content_type(njs_vm_t *vm, n
if (retval != NULL && setval == NULL) {
hdr = &r->headers_out.content_type;
+
+ if (hdr->len == 0) {
+ njs_value_undefined_set(retval);
+ return NJS_OK;
+ }
+
return njs_vm_value_string_set(vm, retval, hdr->data, hdr->len);
}
@@ -3764,6 +3770,12 @@ ngx_http_js_content_type(njs_vm_t *vm, n
if (retval != NULL && setval == NULL) {
hdr = &r->headers_out.content_type;
+
+ if (hdr->len == 0) {
+ njs_value_undefined_set(retval);
+ return NJS_OK;
+ }
+
return njs_vm_value_string_set(vm, retval, hdr->data, hdr->len);
}
More information about the nginx-devel
mailing list