Skip to content

doc: clarify http2 compatibility API example#64235

Open
ChloeVPin wants to merge 1 commit into
nodejs:mainfrom
ChloeVPin:doc/http2-compatibility-api-example
Open

doc: clarify http2 compatibility API example#64235
ChloeVPin wants to merge 1 commit into
nodejs:mainfrom
ChloeVPin:doc/http2-compatibility-api-example

Conversation

@ChloeVPin

Copy link
Copy Markdown

Fixes part of #25952

The introductory Compatibility API example set Content-Type via
setHeader() and then overwrote it in writeHead(), which is confusing
for readers who do not already know that writeHead() merges headers.

This PR:

  • Replaces the example with a straightforward writeHead() call
  • Adds a short note that setHeader() and writeHead() headers are
    merged, with writeHead() taking precedence

The HTTP2_HEADER_* constants documentation is intentionally left for
a separate discussion, per maintainer feedback on the issue.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

Replace the introductory compatibility API example that set the same
header twice with a straightforward writeHead() example. Add a short
note that setHeader() and writeHead() headers are merged, with
writeHead() taking precedence.

Refs: nodejs#25952
Signed-off-by: ChloeVPin <227690662+ChloeVPin@users.noreply.github.com>
@ChloeVPin ChloeVPin force-pushed the doc/http2-compatibility-api-example branch from 47c7a69 to 51f9064 Compare July 1, 2026 16:15
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. http2 Issues or PRs related to the http2 subsystem. labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. http2 Issues or PRs related to the http2 subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants