@@ -252,8 +252,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
252
252
if ( options . socketPath )
253
253
options . path = options . socketPath ;
254
254
255
- if ( ! options . servername && options . servername !== '' )
256
- options . servername = calculateServerName ( options , req ) ;
255
+ normalizeServerName ( options , req ) ;
257
256
258
257
const name = this . getName ( options ) ;
259
258
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 ;
@@ -340,6 +338,11 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
340
338
oncreate ( null , newSocket ) ;
341
339
} ;
342
340
341
+ function normalizeServerName ( options , req ) {
342
+ if ( ! options . servername && options . servername !== '' )
343
+ options . servername = calculateServerName ( options , req ) ;
344
+ }
345
+
343
346
function calculateServerName ( options , req ) {
344
347
let servername = options . host ;
345
348
const hostHeader = req . getHeader ( 'host' ) ;
0 commit comments