Skip to content

http2: add missing setHeaders - #67597

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
jakecastelli:http2-add-setHeaders
Nov 21, 2026
Merged

nodejs-github-bot merged 2 commits into
nodejs:mainfrom
jakecastelli:http2-add-setHeaders

Conversation

@jakecastelli

@jakecastelli jakecastelli commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Reopens / supersedes #51576.

  • Adds Http2ServerResponse.setHeaders() to match http.OutgoingMessage.setHeaders()
  • Includes set-cookie handling consistent with the HTTP implementation
  • Squashed to a single commit with a proper http2: commit message, DCO sign-offs for both authors

Fixes: #51573
Refs: #51576

Original work by @Imperat.

Make it possible to invoke response.setHeaders() on the
Http2ServerResponse object, matching the http.OutgoingMessage API.

Fixes: nodejs#51573
Refs: nodejs#51576
Signed-off-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com>
Signed-off-by: Mikhail Leliakin <leliakin@canva.com>
Co-authored-by: Mikhail Leliakin <leliakin@canva.com>
Assisted-by: Cursor
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added the http2 Issues and PRs related to the http2 subsystem. label Nov 19, 2026
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.71%. Comparing base (b7df44b) to head (0370d7b).
⚠️ Report is 62 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67597      +/-   ##
==========================================
- Coverage   90.73%   90.71%   -0.02%     
==========================================
  Files         801      801              
  Lines      280787   280929     +142     
  Branches    54221    54258      +37     
==========================================
+ Hits       254765   254843      +78     
- Misses      16203    16255      +52     
- Partials     9819     9831      +12     
Files with missing lines Coverage Δ
lib/internal/http2/compat.js 97.40% <100.00%> (+0.10%) ⬆️

... and 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@inoway46

Copy link
Copy Markdown
Contributor

The implementation looks good to me. I think it needs more test coverage. It only covers the happy path, so test cases like the following could be added:

  • Headers instance
  • multiple set-cookie values
  • error cases (ERR_HTTP2_HEADERS_SENT, ERR_INVALID_ARG_TYPE)

And most of the cases in test/parallel/test-http-response-setheaders.js could be ported over.

@jakecastelli jakecastelli added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Nov 20, 2026
Port the cases of test-http-response-setheaders.js: Headers instances,
multiple set-cookie values, replacing headers set before, precedence
of writeHead(), and the `ERR_HTTP2_HEADERS_SENT` and
`ERR_INVALID_ARG_TYPE` errors.

Signed-off-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com>

@inoway46 inoway46 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the tests! This covers the cases I had in mind. Looks good to me.

@jazelly jazelly left a comment

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.

lgtm

@jazelly jazelly added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 21, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 21, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina left a comment

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.

Lgtm

@inoway46 inoway46 added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 21, 2026
@inoway46

Copy link
Copy Markdown
Contributor

Adding the semver-minor label since this PR introduces a new public API, Http2ServerResponse.setHeaders().

@inoway46 inoway46 added author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 21, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 6d426a0 into nodejs:main Nov 21, 2026
81 of 82 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 6d426a0

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. http2 Issues and PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Http2ServerResponse.setHeaders()

5 participants