| 40 | } |
| 41 | |
| 42 | function headersToOutgoing(headers: Headers): http.OutgoingHttpHeaders { |
| 43 | const out: http.OutgoingHttpHeaders = {}; |
| 44 | headers.forEach((value, key) => { |
| 45 | const existing = out[key]; |
| 46 | if (existing === undefined) { |
| 47 | out[key] = value; |
| 48 | return; |
| 49 | } |
| 50 | if (Array.isArray(existing)) { |
| 51 | existing.push(value); |
| 52 | return; |
| 53 | } |
| 54 | out[key] = [String(existing), value]; |
| 55 | }); |
| 56 | return out; |
| 57 | } |
| 58 | |
| 59 | function incomingHeadersToResponseHeaders(headers: http.IncomingHttpHeaders): Headers { |
| 60 | const out = new Headers(); |