| 8803 | } |
| 8804 | __name(shouldSendContentLength, "shouldSendContentLength"); |
| 8805 | function buildRequestHeaders(reqHeaders) { |
| 8806 | const headers = {}; |
| 8807 | for (let n = 0; n < reqHeaders.length; n += 2) { |
| 8808 | const key = reqHeaders[n + 0]; |
| 8809 | const val = reqHeaders[n + 1]; |
| 8810 | const current = headers[key]; |
| 8811 | if (key === "cookie") { |
| 8812 | if (current != null) { |
| 8813 | headers[key] = Array.isArray(current) ? (current.push(val), current) : [current, val]; |
| 8814 | } else { |
| 8815 | headers[key] = val; |
| 8816 | } |
| 8817 | continue; |
| 8818 | } |
| 8819 | if (typeof val === "string") { |
| 8820 | headers[key] = current ? `${current}, ${val}` : val; |
| 8821 | continue; |
| 8822 | } |
| 8823 | for (let i = 0; i < val.length; i++) { |
| 8824 | headers[key] = headers[key] ? `${headers[key]}, ${val[i]}` : val[i]; |
| 8825 | } |
| 8826 | } |
| 8827 | return headers; |
| 8828 | } |
| 8829 | __name(buildRequestHeaders, "buildRequestHeaders"); |
| 8830 | function removeUpgradeStreamListeners(stream) { |
| 8831 | stream.off("response", onUpgradeResponse); |