changeset 1773:3f9b25f36e19

Tests: added js headers tests when value is absent.
author Dmitry Volyntsev <xeioex@nginx.com>
date Tue, 07 Jun 2022 21:28:14 -0700
parents 4f238efded81
children 5a625ce0de34
files js_headers.t
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/js_headers.t
+++ b/js_headers.t
@@ -142,6 +142,15 @@ EOF
     }
 
     function content_length(r) {
+        if (njs.version_number >= 0x000705) {
+            var clength = r.headersOut['Content-Length'];
+            if (clength !== undefined) {
+                r.return(500, `Content-Length "\${clength}" is not empty`);
+                return;
+            }
+        }
+
+        delete r.headersOut['Content-Length'];
         r.headersOut['Content-Length'] = '';
         r.headersOut['Content-Length'] = 3;
         delete r.headersOut['Content-Length'];
@@ -167,6 +176,15 @@ EOF
     }
 
     function content_type(r) {
+        if (njs.version_number >= 0x000705) {
+            var ctype = r.headersOut['Content-Type'];
+            if (ctype !== undefined) {
+                r.return(500, `Content-Type "\${ctype}" is not empty`);
+                return;
+            }
+        }
+
+        delete r.headersOut['Content-Type'];
         r.headersOut['Content-Type'] = 'text/xml';
         r.headersOut['Content-Type'] = '';
         r.headersOut['Content-Type'] = 'text/xml; charset=';
@@ -185,6 +203,15 @@ EOF
     }
 
     function content_encoding(r) {
+        if (njs.version_number >= 0x000705) {
+            var ce = r.headersOut['Content-Encoding'];
+            if (ce !== undefined) {
+                r.return(500, `Content-Encoding "\${ce}" is not empty`);
+                return;
+            }
+        }
+
+        delete r.headersOut['Content-Encoding'];
         r.headersOut['Content-Encoding'] = '';
         r.headersOut['Content-Encoding'] = 'test';
         delete r.headersOut['Content-Encoding'];