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

Function prepareResponseHeadersObject

lib/internal/http2/core.js:2618–2646  ·  view source on GitHub ↗
(oldHeaders, options)

Source from the content-addressed store, hash-verified

2616}
2617
2618function prepareResponseHeadersObject(oldHeaders, options) {
2619 assertIsObject(oldHeaders, 'headers', ['Object', 'Array']);
2620 const headers = { __proto__: null };
2621
2622 if (oldHeaders !== null && oldHeaders !== undefined) {
2623 // This loop is here for performance reason. Do not change.
2624 for (const key in oldHeaders) {
2625 if (ObjectHasOwn(oldHeaders, key)) {
2626 headers[key] = oldHeaders[key];
2627 }
2628 }
2629 headers[kSensitiveHeaders] = oldHeaders[kSensitiveHeaders];
2630 }
2631
2632 const statusCode =
2633 headers[HTTP2_HEADER_STATUS] =
2634 headers[HTTP2_HEADER_STATUS] | 0 || HTTP_STATUS_OK;
2635
2636 if (options.sendDate == null || options.sendDate) {
2637 headers[HTTP2_HEADER_DATE] ??= utcDate();
2638 }
2639
2640 validatePreparedResponseHeaders(headers, statusCode);
2641
2642 return {
2643 headers,
2644 statusCode: headers[HTTP2_HEADER_STATUS],
2645 };
2646}
2647
2648function prepareResponseHeadersArray(headers, options) {
2649 let statusCode;

Callers 3

prepareResponseHeadersFunction · 0.85
respondWithFDMethod · 0.85
respondWithFileMethod · 0.85

Calls 2

utcDateFunction · 0.85

Tested by

no test coverage detected