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

Function calculateServerName

lib/_http_agent.js:479–505  ·  view source on GitHub ↗
(options, req)

Source from the content-addressed store, hash-verified

477}
478
479function calculateServerName(options, req) {
480 let servername = options.host;
481 const hostHeader = req.getHeader('host');
482 if (hostHeader) {
483 validateString(hostHeader, 'options.headers.host');
484
485 // abc => abc
486 // abc:123 => abc
487 // [::1] => ::1
488 // [::1]:123 => ::1
489 if (hostHeader[0] === '[') {
490 const index = hostHeader.indexOf(']');
491 if (index === -1) {
492 // Leading '[', but no ']'. Need to do something...
493 servername = hostHeader;
494 } else {
495 servername = hostHeader.substring(1, index);
496 }
497 } else {
498 servername = hostHeader.split(':', 1)[0];
499 }
500 }
501 // Don't implicitly set invalid (IP) servernames.
502 if (net.isIP(servername))
503 servername = '';
504 return servername;
505}
506
507function installListeners(agent, s, options) {
508 function onFree() {

Callers 1

normalizeServerNameFunction · 0.85

Calls 3

getHeaderMethod · 0.80
indexOfMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…