Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 95644a4

Browse filesBrowse files
ronagaduh95
authored andcommitted
http: lazy allocate cookies array
PR-URL: #59734 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 425a187 commit 95644a4
Copy full SHA for 95644a4

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎lib/_http_outgoing.js‎

Copy file name to clipboardExpand all lines: lib/_http_outgoing.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,20 +673,22 @@ OutgoingMessage.prototype.setHeaders = function setHeaders(headers) {
673673
// We also cannot safely split by comma.
674674
// To avoid setHeader overwriting the previous value we push
675675
// set-cookie values in array and set them all at once.
676-
const cookies = [];
676+
let cookies = null;
677677

678678
for (const { 0: key, 1: value } of headers) {
679679
if (key === 'set-cookie') {
680680
if (ArrayIsArray(value)) {
681+
cookies ??= [];
681682
cookies.push(...value);
682683
} else {
684+
cookies ??= [];
683685
cookies.push(value);
684686
}
685687
continue;
686688
}
687689
this.setHeader(key, value);
688690
}
689-
if (cookies.length) {
691+
if (cookies != null) {
690692
this.setHeader('set-cookie', cookies);
691693
}
692694

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.