MCPcopy Index your code
hub / github.com/nodejs/node / prepareResponseHeadersArray

Function prepareResponseHeadersArray

lib/internal/http2/core.js:2648–2675  ·  view source on GitHub ↗
(headers, options)

Source from the content-addressed store, hash-verified

2646}
2647
2648function 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
2677function validatePreparedResponseHeaders(headers, statusCode) {
2678 // This is intentionally stricter than the HTTP/1 implementation, which

Callers 1

prepareResponseHeadersFunction · 0.85

Calls 4

utcDateFunction · 0.85
unshiftMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…