@@ -1067,7 +1067,7 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
10671067 }
10681068 if ( this . sockets [ name ] . length < this . maxSockets ) {
10691069 // If we are under maxSockets create a new one.
1070- req . onSocket ( this . createSocket ( name , host , port , localAddress , req ) ) ;
1070+ req . onSocket ( this . createSocket ( name , host , port , localAddress ) ) ;
10711071 } else {
10721072 // We are over limit so we'll add it to the queue.
10731073 if ( ! this . requests [ name ] ) {
@@ -1076,13 +1076,13 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
10761076 this . requests [ name ] . push ( req ) ;
10771077 }
10781078} ;
1079- Agent . prototype . createSocket = function ( name , host , port , localAddress , req ) {
1079+ Agent . prototype . createSocket = function ( name , host , port , localAddress ) {
10801080 var self = this ;
10811081 var options = util . _extend ( { } , self . options ) ;
10821082 options . port = port ;
10831083 options . host = host ;
10841084 options . localAddress = localAddress ;
1085- var s = self . createConnection . call ( req , options ) ;
1085+ var s = self . createConnection ( options ) ;
10861086 if ( ! self . sockets [ name ] ) {
10871087 self . sockets [ name ] = [ ] ;
10881088 }
@@ -1123,11 +1123,7 @@ Agent.prototype.removeSocket = function(s, name, host, port, localAddress) {
11231123 }
11241124 if ( this . requests [ name ] && this . requests [ name ] . length ) {
11251125 // If we have pending requests and a socket gets closed a new one
1126- this . createSocket ( name ,
1127- host ,
1128- port ,
1129- localAddress ,
1130- this . requests [ name ] [ 0 ] ) . emit ( 'free' ) ;
1126+ this . createSocket ( name , host , port , localAddress ) . emit ( 'free' ) ;
11311127 }
11321128} ;
11331129
@@ -1139,7 +1135,6 @@ function ClientRequest(options, cb) {
11391135 var self = this ;
11401136 OutgoingMessage . call ( self ) ;
11411137
1142- this . options = util . _extend ( { } , options ) ;
11431138 self . agent = options . agent === undefined ? globalAgent : options . agent ;
11441139
11451140 var defaultPort = options . defaultPort || 80 ;
@@ -1199,7 +1194,7 @@ function ClientRequest(options, cb) {
11991194 self . _last = true ;
12001195 self . shouldKeepAlive = false ;
12011196 if ( options . createConnection ) {
1202- self . onSocket ( options . createConnection . call ( self , self . socketPath ) ) ;
1197+ self . onSocket ( options . createConnection ( self . socketPath ) ) ;
12031198 } else {
12041199 self . onSocket ( net . createConnection ( self . socketPath ) ) ;
12051200 }
@@ -1215,7 +1210,7 @@ function ClientRequest(options, cb) {
12151210 if ( options . createConnection ) {
12161211 options . port = port ;
12171212 options . host = host ;
1218- var conn = options . createConnection . call ( self , options ) ;
1213+ var conn = options . createConnection ( options ) ;
12191214 } else {
12201215 var conn = net . createConnection ( {
12211216 port : port ,
0 commit comments