Welcome! Log In Create A New Profile

Advanced

[njs] HTTP: returing undefined for Content-Type when the header is absent.

Dmitry Volyntsev
June 08, 2022 01:14PM
details: https://hg.nginx.org/njs/rev/cf267407eabe
branches:
changeset: 1879:cf267407eabe
user: Dmitry Volyntsev <xeioex@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);
}

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] HTTP: returing undefined for Content-Type when the header is absent.

Dmitry Volyntsev 361 June 08, 2022 01:14PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready