Skip to content

http: add 'sendingHeaders' event for response header manipulation#63996

Open
bjohansebas wants to merge 1 commit into
nodejs:mainfrom
bjohansebas:on-header-solution
Open

http: add 'sendingHeaders' event for response header manipulation#63996
bjohansebas wants to merge 1 commit into
nodejs:mainfrom
bjohansebas:on-header-solution

Conversation

@bjohansebas

Copy link
Copy Markdown
Member

Okay, after so much time I can finally find time for this. Meanwhile, I’m still testing locally because building Node is quite heavy.

In summary, this serves as a replacement for on-headers, which is a package that does monkey-patching. The idea is to have an event so that middlewares like compression or express-session can use it to modify headers, and for now also, in the case of compression, to transform it into a gzip stream and send the data. However, we will still need two more events to fully remove the monkey-patching of res.write and res.end used in compression, express-session, and many other middlewares

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Jun 19, 2026
Comment thread doc/api/http.md
added: REPLACEME
-->

Emitted synchronously, exactly once, immediately before the status line and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it will be useful to put a sentence as warning when trying to use a promise for a listener.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, and I just added tests as well

Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
@bjohansebas bjohansebas requested a review from mcollina June 19, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants