@@ -253,8 +253,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
253
253
if ( options . socketPath )
254
254
options . path = options . socketPath ;
255
255
256
- if ( ! options . servername && options . servername !== '' )
257
- options . servername = calculateServerName ( options , req ) ;
256
+ normalizeServerName ( options , req ) ;
258
257
259
258
const name = this . getName ( options ) ;
260
259
if ( ! this . sockets [ name ] ) {
@@ -313,8 +312,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
313
312
if ( options . socketPath )
314
313
options . path = options . socketPath ;
315
314
316
- if ( ! options . servername && options . servername !== '' )
317
- options . servername = calculateServerName ( options , req ) ;
315
+ normalizeServerName ( options , req ) ;
318
316
319
317
const name = this . getName ( options ) ;
320
318
options . _agentKey = name ;
@@ -344,6 +342,11 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
344
342
oncreate ( null , newSocket ) ;
345
343
} ;
346
344
345
+ function normalizeServerName ( options , req ) {
346
+ if ( ! options . servername && options . servername !== '' )
347
+ options . servername = calculateServerName ( options , req ) ;
348
+ }
349
+
347
350
function calculateServerName ( options , req ) {
348
351
let servername = options . host ;
349
352
const hostHeader = req . getHeader ( 'host' ) ;
0 commit comments