FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

http: allow passing array of key/val into writeHead by ronag · Pull Request #35274 · nodejs/node · GitHub

/ node Public

http: allow passing array of key/val into writeHead - #35274

Closed
ronag wants to merge 6 commits into
nodejs:masterfrom
nxtedition:write-head-array
Closed

http: allow passing array of key/val into writeHead#35274
ronag wants to merge 6 commits into
nodejs:masterfrom
nxtedition:write-head-array

Conversation

ronag commented Sep 20, 2020

Copy link
Copy Markdown
Member

Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

ronag requested a review from mcollina September 20, 2020 07:33
ronag requested a review from a team as a code owner September 20, 2020 07:33

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Sep 20, 2020
Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.
Comment thread lib/_http_server.js

Copy link
Copy Markdown
Member

This needs docs changes, right?

ronag commented Sep 20, 2020

Copy link
Copy Markdown
Member Author

@addaleax Added docs

Comment thread doc/api/http.md

Copy link
Copy Markdown
Member

Enables an optimization when the user already has the headers in an array form, e.g. when proxying.

Why would proxying imply the user gets the headers in array form?

ronag commented Sep 21, 2020

Copy link
Copy Markdown
Member Author

undici provides them in array form

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

ronag commented Sep 21, 2020

Copy link
Copy Markdown
Member Author

@benjamingr Here we would benefit from being able to pass the array directly without first converting it into an object.

ronag added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. labels Sep 21, 2020
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 21, 2020

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

I still don't understand this feature request/PR. Is this is a specific format that afaik only unidici uses?

Wouldn't it make more sense to support raw headers as a string?

ronag commented Sep 22, 2020

Copy link
Copy Markdown
Member Author

Is this is a specific format that afaik only unidici uses?

At the moment yes... since Node doesn't have this feature yet no one has optimized for it as far as I'm aware...

Wouldn't it make more sense to support raw headers as a string?

Sure... But since we already do arrays I don't see any advantage. I guess one does not exclude the other.

Copy link
Copy Markdown
Member

Sure... But since we already do arrays I don't see any advantage. I guess one does not exclude the other.

I'm confused by this. This is an intermediary format that only one library uses. Passing a string of headers (concatenated) is something I've seen in many servers/languages.

Would the optimisation be impossible without going through the third (array) format?

ronag commented Sep 22, 2020
edited
Loading

Copy link
Copy Markdown
Member Author

I'm confused by this.

Due to the way our http parser works the most efficient way to get headers from node is through arrays (i.e. rawHeaders & rawTrailers). If we pass it as string it becomes inefficient to process the headers.

For best performance in core and user land should use flat arrays for headers. Strings don't allow efficient introspection and objects are expensive to create.

@mcollina maybe you are able to formulate this better?

Comment thread lib/_http_server.js
Trott added the semver-minor PRs that contain new features and should be released in the next minor version. label Sep 22, 2020

lpinca commented Sep 22, 2020

Copy link
Copy Markdown
Member

For best performance in core and user land should use flat arrays for headers. Strings don't allow efficient introspection and objects are expensive to create.

Do you have any benchmark for this? How much faster is creating an array instead of a plain object? Or is this related to how the HTTP parser works?

ronag commented Sep 22, 2020

Copy link
Copy Markdown
Member Author

Do you have any benchmark for this? How much faster is creating an array instead of a plain object? Or is this related to how the HTTP parser works?

The parser outputs an Array.

lpinca commented Sep 22, 2020
edited
Loading

Copy link
Copy Markdown
Member

Ok, but in this case the parser is not used no? Isn't OutgoingMessage writing directly to the socket?

Edit: Ah I get it now, it's for proxying. I guess the idea is to get the headers as received by the parser and directly forward them.

ronag requested a review from addaleax September 30, 2020 18:41
ronag added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Sep 30, 2020

ronag commented Sep 30, 2020

Copy link
Copy Markdown
Member Author

@benjamingr comment added

github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 30, 2020

Copy link
Copy Markdown
Collaborator

ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2020
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2020

Copy link
Copy Markdown
Collaborator

ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2020
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 9, 2020

Copy link
Copy Markdown
Collaborator

ronag added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 9, 2020
github-actions Bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 9, 2020

github-actions Bot commented Oct 9, 2020

Copy link
Copy Markdown
Contributor
Commit Queue failed
- Loading data for nodejs/node/pull/35274
✔  Done loading data for nodejs/node/pull/35274
----------------------------------- PR info ------------------------------------
Title      http: allow passing array of key/val into writeHead (#35274)
Author     Robert Nagy  (@ronag)
Branch     ronag:write-head-array -> nodejs:master
Labels     author ready, http, semver-minor
Commits    6
 - http: allow passing array of key/val into writeHead
 - fixup: docs
 - fixup
 - fixup
 - fixup
 - fixup
Committers 1
 - Robert Nagy 
PR-URL: https://github.com/nodejs/node/pull/35274
Reviewed-By: Matteo Collina 
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Rich Trott 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/35274
Reviewed-By: Matteo Collina 
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Rich Trott 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - fixup
   ⚠  - fixup
   ✔  Last GitHub Actions successful
   ℹ  Last Full PR CI on 2020-10-09T12:42:51Z: https://ci.nodejs.org/job/node-test-pull-request/33490/
- Querying data for job/node-test-pull-request/33490/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
   ℹ  This PR was created on Sun, 20 Sep 2020 07:33:30 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/35274#pullrequestreview-492926190
   ✔  - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/35274#pullrequestreview-494531574
   ✔  - Rich Trott (@Trott) (TSC): https://github.com/nodejs/node/pull/35274#pullrequestreview-494545046
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
\nCommit Queue action: https://github.com/nodejs/node/actions/runs/298285943

github-actions Bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Oct 9, 2020

ronag commented Oct 10, 2020

Copy link
Copy Markdown
Member Author

Landed in d70c0ed

ronag closed this Oct 10, 2020
ronag added a commit that referenced this pull request Oct 10, 2020
Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.

PR-URL: #35274
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 14, 2020
Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.

PR-URL: #35274
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins added a commit that referenced this pull request Oct 14, 2020
Notable changes:

crypto:
  * update certdata to NSS 3.56 (Shelley Vohr) #35546
doc:
  * add aduh95 to collaborators (Antoine du Hamel) #35542
fs:
  * (SEMVER-MINOR) add rm method (Ian Sutherland) #35494
http:
  * (SEMVER-MINOR) allow passing array of key/val into writeHead (Robert Nagy) #35274
src:
  * (SEMVER-MINOR) expose v8::Isolate setup callbacks (Shelley Vohr) #35512

PR-URL: TODO
MylesBorins mentioned this pull request Oct 14, 2020
MylesBorins added a commit that referenced this pull request Oct 15, 2020
Notable changes:

crypto:
  * update certdata to NSS 3.56 (Shelley Vohr) #35546
doc:
  * add aduh95 to collaborators (Antoine du Hamel) #35542
fs:
  * (SEMVER-MINOR) add rm method (Ian Sutherland) #35494
http:
  * (SEMVER-MINOR) allow passing array of key/val into writeHead (Robert Nagy) #35274
src:
  * (SEMVER-MINOR) expose v8::Isolate setup callbacks (Shelley Vohr) #35512

PR-URL: TODO
MylesBorins added a commit that referenced this pull request Oct 15, 2020
Notable changes:

crypto:
  * update certdata to NSS 3.56 (Shelley Vohr) #35546
doc:
  * add aduh95 to collaborators (Antoine du Hamel) #35542
fs:
  * (SEMVER-MINOR) add rm method (Ian Sutherland) #35494
http:
  * (SEMVER-MINOR) allow passing array of key/val into writeHead (Robert Nagy) #35274
src:
  * (SEMVER-MINOR) expose v8::Isolate setup callbacks (Shelley Vohr) #35512

PR-URL: #35648
MylesBorins added a commit that referenced this pull request Oct 16, 2020
Notable changes:

crypto:
  * update certdata to NSS 3.56 (Shelley Vohr) #35546
doc:
  * add aduh95 to collaborators (Antoine du Hamel) #35542
fs:
  * (SEMVER-MINOR) add rm method (Ian Sutherland) #35494
http:
  * (SEMVER-MINOR) allow passing array of key/val into writeHead (Robert Nagy) #35274
src:
  * (SEMVER-MINOR) expose v8::Isolate setup callbacks (Shelley Vohr) #35512

PR-URL: #35648
joesepi pushed a commit to joesepi/node that referenced this pull request Jan 8, 2021
Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.

PR-URL: nodejs#35274
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos removed the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Sep 5, 2021
ryanhc pushed a commit to Samsung/lwnode that referenced this pull request Jun 29, 2022
Notable changes:

crypto:
  * update certdata to NSS 3.56 (Shelley Vohr) nodejs/node#35546
doc:
  * add aduh95 to collaborators (Antoine du Hamel) nodejs/node#35542
fs:
  * (SEMVER-MINOR) add rm method (Ian Sutherland) nodejs/node#35494
http:
  * (SEMVER-MINOR) allow passing array of key/val into writeHead (Robert Nagy) nodejs/node#35274
src:
  * (SEMVER-MINOR) expose v8::Isolate setup callbacks (Shelley Vohr) nodejs/node#35512

PR-URL: nodejs/node#35648
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. http Issues or PRs related to the http subsystem. 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.

8 participants


Back | FazBrowse Home | New Git URL