setHeader / setHeaders have a protection against a mistake:
|
OutgoingMessage.prototype.setHeader = function setHeader(name, value) { |
|
if (this._header) { |
|
throw new ERR_HTTP_HEADERS_SENT('set'); |
|
} |
|
OutgoingMessage.prototype.setHeaders = function setHeaders(headers) { |
|
if (this._header) { |
|
throw new ERR_HTTP_HEADERS_SENT('set'); |
|
} |
addTrailers doesn't, and just assigns to ._trailers _even if the response is already ended/sent.
|
OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { |
|
this._trailer = ''; |
|
const keys = ObjectKeys(headers); |
Note: adding this check would be a semver-major change.
E.g. fastify incorrectly attempts to do this under some conditions due to a logic mistake.
setHeader/setHeadershave a protection against a mistake:node/lib/_http_outgoing.js
Lines 645 to 648 in adeb14a
node/lib/_http_outgoing.js
Lines 660 to 663 in adeb14a
addTrailersdoesn't, and just assigns to._trailers_even if the response is already ended/sent.node/lib/_http_outgoing.js
Lines 984 to 986 in adeb14a
Note: adding this check would be a semver-major change.
E.g.
fastifyincorrectly attempts to do this under some conditions due to a logic mistake.