nodejs / nodejs/node

Missing `Http2ServerResponse.setHeaders()`

Open
#51,573 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request http2
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

Make it possible to use response.setHeaders() on both old HTTP response objects and ones coming from node:http2.

BTW I wasn't sure if this should be a "feature request" or a "bug."

What is the feature you are proposing to solve the problem?

Add the method http2.Http2ServerResponse.setHeaders() to have the same API as http.OutgoingMessage.setHeaders().

See https://nodejs.org/api/http.html#outgoingmessagesetheadersheaders.

What alternatives have you considered?
  • Avoiding using setHeaders() at all.
  • Monkey-patching Http2ServerResponse.
  • Just writing two versions of my own set-headers code, on the assumption that, when available, setHeaders() is the most efficient option.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the node:http2 Http2ServerResponse entry point and compare its API with http.OutgoingMessage.setHeaders(), using the linked HTTP documentation as the behavioral reference. Done means Http2ServerResponse exposes setHeaders() with the same API and behavior as the existing HTTP response objects, with appropriate coverage for the new method.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.