@@ -110,7 +110,7 @@ function ClientRequest(input, options, cb) {
110
110
options = Object . assign ( input || { } , options ) ;
111
111
}
112
112
113
- var agent = options . agent ;
113
+ let agent = options . agent ;
114
114
const defaultAgent = options . _defaultAgent || Agent . globalAgent ;
115
115
if ( agent === false ) {
116
116
agent = new defaultAgent . constructor ( ) ;
@@ -128,11 +128,11 @@ function ClientRequest(input, options, cb) {
128
128
this . agent = agent ;
129
129
130
130
const protocol = options . protocol || defaultAgent . protocol ;
131
- var expectedProtocol = defaultAgent . protocol ;
131
+ let expectedProtocol = defaultAgent . protocol ;
132
132
if ( this . agent && this . agent . protocol )
133
133
expectedProtocol = this . agent . protocol ;
134
134
135
- var path ;
135
+ let path ;
136
136
if ( options . path ) {
137
137
path = String ( options . path ) ;
138
138
if ( INVALID_PATH_REGEX . test ( path ) )
@@ -157,7 +157,7 @@ function ClientRequest(input, options, cb) {
157
157
if ( options . timeout !== undefined )
158
158
this . timeout = getTimerDuration ( options . timeout , 'timeout' ) ;
159
159
160
- var method = options . method ;
160
+ let method = options . method ;
161
161
const methodIsString = ( typeof method === 'string' ) ;
162
162
if ( method !== null && method !== undefined && ! methodIsString ) {
163
163
throw new ERR_INVALID_ARG_TYPE ( 'method' , 'string' , method ) ;
@@ -196,7 +196,7 @@ function ClientRequest(input, options, cb) {
196
196
this . parser = null ;
197
197
this . maxHeadersCount = null ;
198
198
199
- var called = false ;
199
+ let called = false ;
200
200
201
201
if ( this . agent ) {
202
202
// If there is an agent we should default to Connection:keep-alive,
@@ -215,20 +215,20 @@ function ClientRequest(input, options, cb) {
215
215
const headersArray = Array . isArray ( options . headers ) ;
216
216
if ( ! headersArray ) {
217
217
if ( options . headers ) {
218
- var keys = Object . keys ( options . headers ) ;
219
- for ( var i = 0 ; i < keys . length ; i ++ ) {
220
- var key = keys [ i ] ;
218
+ const keys = Object . keys ( options . headers ) ;
219
+ for ( let i = 0 ; i < keys . length ; i ++ ) {
220
+ const key = keys [ i ] ;
221
221
this . setHeader ( key , options . headers [ key ] ) ;
222
222
}
223
223
}
224
224
225
225
if ( host && ! this . getHeader ( 'host' ) && setHost ) {
226
- var hostHeader = host ;
226
+ let hostHeader = host ;
227
227
228
228
// For the Host header, ensure that IPv6 addresses are enclosed
229
229
// in square brackets, as defined by URI formatting
230
230
// https://tools.ietf.org/html/rfc3986#section-3.2.2
231
- var posColon = hostHeader . indexOf ( ':' ) ;
231
+ const posColon = hostHeader . indexOf ( ':' ) ;
232
232
if ( posColon !== - 1 &&
233
233
hostHeader . includes ( ':' , posColon + 1 ) &&
234
234
hostHeader . charCodeAt ( 0 ) !== 91 /* '[' */ ) {
@@ -463,8 +463,8 @@ function socketOnData(d) {
463
463
req . emit ( 'error' , ret ) ;
464
464
} else if ( parser . incoming && parser . incoming . upgrade ) {
465
465
// Upgrade (if status code 101) or CONNECT
466
- var bytesParsed = ret ;
467
- var res = parser . incoming ;
466
+ const bytesParsed = ret ;
467
+ const res = parser . incoming ;
468
468
req . res = res ;
469
469
470
470
socket . removeListener ( 'data' , socketOnData ) ;
@@ -473,9 +473,9 @@ function socketOnData(d) {
473
473
parser . finish ( ) ;
474
474
freeParser ( parser , req , socket ) ;
475
475
476
- var bodyHead = d . slice ( bytesParsed , d . length ) ;
476
+ const bodyHead = d . slice ( bytesParsed , d . length ) ;
477
477
478
- var eventName = req . method === 'CONNECT' ? 'connect' : 'upgrade' ;
478
+ const eventName = req . method === 'CONNECT' ? 'connect' : 'upgrade' ;
479
479
if ( req . listenerCount ( eventName ) > 0 ) {
480
480
req . upgradeOrConnect = true ;
481
481
0 commit comments