fix: use hasContentLen instead of hasContentLength for header removal

Use the post-headers flag (hasContentLen) that reflects the effective
headers after writeHead() obj headers are applied, rather than the
initial hasContentLength value.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2026-01-16 18:15:20 +00:00
parent 7ab5cf7a34
commit 960e5db2fe

View File

@@ -1187,7 +1187,8 @@ function _writeHead(statusCode, reason, obj, response) {
// Trailers cannot be used without chunked encoding
if (response.hasHeader("trailer")) {
// If "Trailer" header is explicitly set, that's an error
if (hasContentLength) {
// Use hasContentLen (not hasContentLength) to reflect current headers after obj applied
if (hasContentLen) {
response.removeHeader("trailer");
} else {
response.removeHeader("content-length");