FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add a check to not allow `addTrailers` on an already ended http reply · Issue #62809 · nodejs/node · GitHub

/ node Public

Add a check to not allow addTrailers on an already ended http reply #62809

Description

setHeader / setHeaders have a protection against a mistake:

node/lib/_http_outgoing.js

Lines 645 to 648 in adeb14a

OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
if (this._header) {
throw new ERR_HTTP_HEADERS_SENT('set');
}

node/lib/_http_outgoing.js

Lines 660 to 663 in adeb14a

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.

node/lib/_http_outgoing.js

Lines 984 to 986 in adeb14a

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL