(headers, sensitiveHeaders)
| 896 | ); |
| 897 | |
| 898 | function toHeaderObject(headers, sensitiveHeaders) { |
| 899 | const obj = { __proto__: null }; |
| 900 | for (let n = 0; n < headers.length; n += 2) { |
| 901 | const name = headers[n]; |
| 902 | let value = headers[n + 1]; |
| 903 | if (name === HTTP2_HEADER_STATUS) |
| 904 | value |= 0; |
| 905 | const existing = obj[name]; |
| 906 | if (existing === undefined) { |
| 907 | obj[name] = name === HTTP2_HEADER_SET_COOKIE ? [value] : value; |
| 908 | } else if (!kSingleValueFields.has(name)) { |
| 909 | switch (name) { |
| 910 | case HTTP2_HEADER_COOKIE: |
| 911 | // https://tools.ietf.org/html/rfc7540#section-8.1.2.5 |
| 912 | // "...If there are multiple Cookie header fields after decompression, |
| 913 | // these MUST be concatenated into a single octet string using the |
| 914 | // two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ") before |
| 915 | // being passed into a non-HTTP/2 context." |
| 916 | obj[name] = `${existing}; ${value}`; |
| 917 | break; |
| 918 | case HTTP2_HEADER_SET_COOKIE: |
| 919 | // https://tools.ietf.org/html/rfc7230#section-3.2.2 |
| 920 | // "Note: In practice, the "Set-Cookie" header field ([RFC6265]) often |
| 921 | // appears multiple times in a response message and does not use the |
| 922 | // list syntax, violating the above requirements on multiple header |
| 923 | // fields with the same name. Since it cannot be combined into a |
| 924 | // single field-value, recipients ought to handle "Set-Cookie" as a |
| 925 | // special case while processing header fields." |
| 926 | existing.push(value); |
| 927 | break; |
| 928 | default: |
| 929 | // https://tools.ietf.org/html/rfc7230#section-3.2.2 |
| 930 | // "A recipient MAY combine multiple header fields with the same field |
| 931 | // name into one "field-name: field-value" pair, without changing the |
| 932 | // semantics of the message, by appending each subsequent field value |
| 933 | // to the combined field value in order, separated by a comma." |
| 934 | obj[name] = `${existing}, ${value}`; |
| 935 | break; |
| 936 | } |
| 937 | } |
| 938 | } |
| 939 | obj[kSensitiveHeaders] = sensitiveHeaders; |
| 940 | return obj; |
| 941 | } |
| 942 | |
| 943 | function isPayloadMeaningless(method) { |
| 944 | return kNoPayloadMethods.has(method); |
no test coverage detected
searching dependent graphs…