GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: lazy allocate cookies array · nodejs/node@95644a4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _http_outgoing.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.