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

Function processHeader

lib/_http_outgoing.js:567–600  ·  view source on GitHub ↗
(self, state, key, value, validate, lenient)

Source from the content-addressed store, hash-verified

565}
566
567function processHeader(self, state, key, value, validate, lenient) {
568 if (validate)
569 validateHeaderName(key);
570
571 // If key is content-disposition and there is content-length
572 // encode the value in latin1
573 // https://www.rfc-editor.org/rfc/rfc6266#section-4.3
574 // Refs: https://github.com/nodejs/node/pull/46528
575 if (isContentDispositionField(key) && self._contentLength) {
576 // The value could be an array here
577 if (ArrayIsArray(value)) {
578 for (let i = 0; i < value.length; i++) {
579 value[i] = Buffer.from(value[i], 'latin1');
580 }
581 } else {
582 value = Buffer.from(value, 'latin1');
583 }
584 }
585
586 if (ArrayIsArray(value)) {
587 if (
588 (value.length < 2 || !isCookieField(key)) &&
589 (!self[kUniqueHeaders] || !self[kUniqueHeaders].has(key.toLowerCase()))
590 ) {
591 // Retain for(;;) loop for performance reasons
592 // Refs: https://github.com/nodejs/node/pull/30958
593 for (let i = 0; i < value.length; i++)
594 storeHeader(self, state, key, value[i], validate, lenient);
595 return;
596 }
597 value = value.join('; ');
598 }
599 storeHeader(self, state, key, value, validate, lenient);
600}
601
602function storeHeader(self, state, key, value, validate, lenient) {
603 if (validate)

Callers 1

_storeHeaderFunction · 0.70

Calls 6

isCookieFieldFunction · 0.85
storeHeaderFunction · 0.85
hasMethod · 0.65
fromMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…