-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: allow passing array of key/val into writeHead #35274
Conversation
Review requested:
|
Enables an optimization when the user already has the headers in an array form, e.g. when proxying.
c308f0f
to
7c3bcf5
Compare
This needs docs changes, right? |
@addaleax Added docs |
23d54d9
to
f8f3e05
Compare
Why would proxying imply the user gets the headers in array form? |
undici provides them in array form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@benjamingr Here we would benefit from being able to pass the array directly without first converting it into an object. |
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? |
At the moment yes... since Node doesn't have this feature yet no one has optimized for it as far as I'm aware...
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? |
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? |
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. |
Ok, but in this case the parser is not used no? Isn't 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. |
@benjamingr comment added |
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 |
Landed in d70c0ed |
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
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
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
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
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
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
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
Enables an optimization when the user already has the headers
in an array form, e.g. when proxying.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes