| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0a03e35 commit b61a08c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -403,13 +403,14 @@ function mapToHeaders(map, | |||
| 403 | 403 | if (typeof key === 'symbol' || value === undefined || !key) | |
| 404 | 404 | continue; | |
| 405 | 405 | key = String(key).toLowerCase(); | |
| 406 | - const isArray = Array.isArray(value); | ||
| 406 | + let isArray = Array.isArray(value); | ||
| 407 | 407 | if (isArray) { | |
| 408 | 408 | switch (value.length) { | |
| 409 | 409 | case 0: | |
| 410 | 410 | continue; | |
| 411 | 411 | case 1: | |
| 412 | 412 | value = String(value[0]); | |
| 413 | + isArray = false; | ||
| 413 | 414 | break; | |
| 414 | 415 | default: | |
| 415 | 416 | if (kSingleValueHeaders.has(key)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,6 +154,18 @@ const { | |||
| 154 | 154 | ); | |
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | + { | ||
| 158 | + // Arrays containing a single set-cookie value are handled correctly | ||
| 159 | + // (https://github.com/nodejs/node/issues/16452) | ||
| 160 | + const headers = { | ||
| 161 | + 'set-cookie': 'foo=bar' | ||
| 162 | + }; | ||
| 163 | + assert.deepStrictEqual( | ||
| 164 | + mapToHeaders(headers), | ||
| 165 | + [ [ 'set-cookie', 'foo=bar', '' ].join('\0'), 1 ] | ||
| 166 | + ); | ||
| 167 | + } | ||
| 168 | + | ||
| 157 | 169 | // The following are not allowed to have multiple values | |
| 158 | 170 | [ | |
| 159 | 171 | HTTP2_HEADER_STATUS, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments