]> git.kaiwu.me - njs.git/commit
Fetch: preserve QuickJS header names
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 13 Aug 2026 00:22:55 +0000 (17:22 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 13 Aug 2026 14:00:21 +0000 (07:00 -0700)
commit3388e416967f3aeef3c853af2c523844f37e068c
tree80bd23492e92046d475a9e2d8ce2f5041367e374
parent138c184ef47b6b9405f1fb60fa28a87b5b701830
Fetch: preserve QuickJS header names

Previously, Headers.set() converted the header name with
JS_ToCStringLen().  When a new header was added, the list retained that
pointer after it was released with JS_FreeCString(), leaving the header
with a dangling name.

The fix is to copy the name into the request pool only when set() creates
a new list entry.  Replacing an existing entry requires no additional
allocation, and the temporary QuickJS string can always be released
after the mutation.
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