@@ -1067,7 +1067,7 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
1067
1067
}
1068
1068
if ( this . sockets [ name ] . length < this . maxSockets ) {
1069
1069
// 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 ) ) ;
1071
1071
} else {
1072
1072
// We are over limit so we'll add it to the queue.
1073
1073
if ( ! this . requests [ name ] ) {
@@ -1076,13 +1076,13 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
1076
1076
this . requests [ name ] . push ( req ) ;
1077
1077
}
1078
1078
} ;
1079
- Agent . prototype . createSocket = function ( name , host , port , localAddress , req ) {
1079
+ Agent . prototype . createSocket = function ( name , host , port , localAddress ) {
1080
1080
var self = this ;
1081
1081
var options = util . _extend ( { } , self . options ) ;
1082
1082
options . port = port ;
1083
1083
options . host = host ;
1084
1084
options . localAddress = localAddress ;
1085
- var s = self . createConnection . call ( req , options ) ;
1085
+ var s = self . createConnection ( options ) ;
1086
1086
if ( ! self . sockets [ name ] ) {
1087
1087
self . sockets [ name ] = [ ] ;
1088
1088
}
@@ -1123,11 +1123,7 @@ Agent.prototype.removeSocket = function(s, name, host, port, localAddress) {
1123
1123
}
1124
1124
if ( this . requests [ name ] && this . requests [ name ] . length ) {
1125
1125
// 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' ) ;
1131
1127
}
1132
1128
} ;
1133
1129
@@ -1139,7 +1135,6 @@ function ClientRequest(options, cb) {
1139
1135
var self = this ;
1140
1136
OutgoingMessage . call ( self ) ;
1141
1137
1142
- this . options = util . _extend ( { } , options ) ;
1143
1138
self . agent = options . agent === undefined ? globalAgent : options . agent ;
1144
1139
1145
1140
var defaultPort = options . defaultPort || 80 ;
@@ -1199,7 +1194,7 @@ function ClientRequest(options, cb) {
1199
1194
self . _last = true ;
1200
1195
self . shouldKeepAlive = false ;
1201
1196
if ( options . createConnection ) {
1202
- self . onSocket ( options . createConnection . call ( self , self . socketPath ) ) ;
1197
+ self . onSocket ( options . createConnection ( self . socketPath ) ) ;
1203
1198
} else {
1204
1199
self . onSocket ( net . createConnection ( self . socketPath ) ) ;
1205
1200
}
@@ -1215,7 +1210,7 @@ function ClientRequest(options, cb) {
1215
1210
if ( options . createConnection ) {
1216
1211
options . port = port ;
1217
1212
options . host = host ;
1218
- var conn = options . createConnection . call ( self , options ) ;
1213
+ var conn = options . createConnection ( options ) ;
1219
1214
} else {
1220
1215
var conn = net . createConnection ( {
1221
1216
port : port ,
0 commit comments