]> git.kaiwu.me - njs.git/commit
Fetch: centralize Headers mutations
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 13 Aug 2026 00:22:31 +0000 (17:22 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 13 Aug 2026 14:00:21 +0000 (07:00 -0700)
commit138c184ef47b6b9405f1fb60fa28a87b5b701830
treeded763f0ef0b1ebfe5357bbb5a09c7bbbb63e2df
parent4bce5f0e7739984b1fb995625baf8ba698f231b5
Fetch: centralize Headers mutations

Previously, Headers.set() validated its arguments only when the header
did not already exist.  Existing values were overwritten without
trimming or validating the new value and without checking the immutable
guard.  It also detached duplicate values only from the first header's
chain, while leaving the corresponding list entries active.  The stale
values could reappear when the Headers object was copied or serialized.

The fix is to move append(), set(), and delete() validation and list
updates into engine-independent helpers, deactivate every duplicate on
replacement, reject empty names, and enforce immutable guards
consistently.  Content-Type presence is now derived from the header list
instead of a separate cached pointer.

Reported by vladimirelitokarev@gmail.com.
nginx/ngx_js_fetch.c
nginx/ngx_js_http.c
nginx/ngx_js_http.h
nginx/ngx_qjs_fetch.c
nginx/t/js_fetch_objects.t