(headers, options)
| 2646 | } |
| 2647 | |
| 2648 | function prepareResponseHeadersArray(headers, options) { |
| 2649 | let statusCode; |
| 2650 | let isDateSet = false; |
| 2651 | |
| 2652 | for (let i = 0; i < headers.length; i += 2) { |
| 2653 | const header = headers[i].toLowerCase(); |
| 2654 | const value = headers[i + 1]; |
| 2655 | |
| 2656 | if (header === HTTP2_HEADER_STATUS) { |
| 2657 | statusCode = value | 0; |
| 2658 | } else if (header === HTTP2_HEADER_DATE) { |
| 2659 | isDateSet = true; |
| 2660 | } |
| 2661 | } |
| 2662 | |
| 2663 | if (!statusCode) { |
| 2664 | statusCode = HTTP_STATUS_OK; |
| 2665 | headers.unshift(HTTP2_HEADER_STATUS, statusCode); |
| 2666 | } |
| 2667 | |
| 2668 | if (!isDateSet && (options.sendDate == null || options.sendDate)) { |
| 2669 | headers.push(HTTP2_HEADER_DATE, utcDate()); |
| 2670 | } |
| 2671 | |
| 2672 | validatePreparedResponseHeaders(headers, statusCode); |
| 2673 | |
| 2674 | return { headers, statusCode }; |
| 2675 | } |
| 2676 | |
| 2677 | function validatePreparedResponseHeaders(headers, statusCode) { |
| 2678 | // This is intentionally stricter than the HTTP/1 implementation, which |
no test coverage detected
searching dependent graphs…