[njs] HTTP: fixed r.headersOut special getters when value is absent.

Dmitry Volyntsev xeioex at nginx.com
Wed Jun 8 17:13:10 UTC 2022


details:   https://hg.nginx.org/njs/rev/6ef77c24c924
branches:  
changeset: 1878:6ef77c24c924
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Jun 06 23:27:11 2022 -0700
description:
HTTP: fixed r.headersOut special getters when value is absent.

Previously, when Content-Encoding or Content-Length header was absent,
an exception was thrown erroneously.

This closes #537 issue on Github.

diffstat:

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

diffs (39 lines):

diff -r 9c4858617097 -r 6ef77c24c924 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Fri Jun 03 23:24:12 2022 -0700
+++ b/nginx/ngx_http_js_module.c	Mon Jun 06 23:27:11 2022 -0700
@@ -1900,7 +1900,7 @@ ngx_http_js_content_encoding(njs_vm_t *v
     ngx_table_elt_t  *h;
 
     rc = ngx_http_js_header_out_special(vm, r, v, setval, retval, &h);
-    if (rc != NJS_OK) {
+    if (rc == NJS_ERROR) {
         return NJS_ERROR;
     }
 
@@ -1940,7 +1940,7 @@ ngx_http_js_content_length(njs_vm_t *vm,
     }
 
     rc = ngx_http_js_header_out_special(vm, r, v, setval, retval, &h);
-    if (rc != NJS_OK) {
+    if (rc == NJS_ERROR) {
         return NJS_ERROR;
     }
 
@@ -3686,7 +3686,7 @@ ngx_http_js_content_encoding(njs_vm_t *v
     ngx_table_elt_t  *h;
 
     rc = ngx_http_js_header_out_special(vm, r, v, setval, retval, &h);
-    if (rc != NJS_OK) {
+    if (rc == NJS_ERROR) {
         return NJS_ERROR;
     }
 
@@ -3726,7 +3726,7 @@ ngx_http_js_content_length(njs_vm_t *vm,
     }
 
     rc = ngx_http_js_header_out_special(vm, r, v, setval, retval, &h);
-    if (rc != NJS_OK) {
+    if (rc == NJS_ERROR) {
         return NJS_ERROR;
     }
 



More information about the nginx-devel mailing list