Skip to content

http: create header field names as internalized strings#64277

Open
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:http-internalize-header-names
Open

http: create header field names as internalized strings#64277
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:http-internalize-header-names

Conversation

@araujogui

Copy link
Copy Markdown
Member

Internalize header field names so repeated occurrences resolve to the same string in the isolate's string table, speeding up matchKnownFields() comparisons and req.headers builds.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Copilot AI review requested due to automatic review settings July 4, 2026 03:16
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http_parser Issues and PRs related to the HTTP Parser dependency or the http_parser binding. needs-ci PRs that need a full CI run. labels Jul 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes HTTP header processing by internalizing header field name strings so repeated header names can compare faster (e.g., in JS matchKnownFields()) and reduce duplicate string allocations when building req.headers.

Changes:

  • Add StringPtr::ToInternalizedString() to create V8 internalized strings from header field names.
  • Use internalized strings for header field names when constructing the headers array passed to JS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/node_http_parser.cc
Comment on lines +237 to +246
Local<String> ToInternalizedString(Environment* env) const {
if (size_ != 0) {
return String::NewFromOneByte(env->isolate(),
reinterpret_cast<const uint8_t*>(str_),
NewStringType::kInternalized,
size_)
.ToLocalChecked();
}
return String::Empty(env->isolate());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. http_parser Issues and PRs related to the HTTP Parser dependency or the http_parser binding. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants