@@ -33,9 +33,9 @@ var httpRequest = function (options) {
33
33
34
34
var parsedUrl = url . parse ( uri ) ;
35
35
var protocol = parsedUrl . protocol . replace ( ':' , '' ) ;
36
- var interface = protocol === 'http' ? http : https ;
36
+ var protocolInterface = protocol === 'http' ? http : https ;
37
37
38
- var options = {
38
+ var internalOptions = {
39
39
hostname : parsedUrl . hostname ,
40
40
port : parsedUrl . port ,
41
41
path : parsedUrl . path ,
@@ -51,27 +51,25 @@ var httpRequest = function (options) {
51
51
* is unsuitable for environments where requests are expected to be
52
52
* using end-to-end TLS.
53
53
*/
54
- interface = http ;
55
- const proxyUrl = url . parse ( process . env . http_proxy ) ;
56
- options = {
54
+ protocolInterface = http ;
55
+ var proxyUrl = url . parse ( process . env . http_proxy ) ;
56
+ headers . host = parsedUrl . host ;
57
+ internalOptions = {
57
58
hostname : proxyUrl . hostname ,
58
59
port : proxyUrl . port ,
59
60
path : parsedUrl . href ,
60
61
method : method ,
61
62
timeout : timeout ,
62
- headers : {
63
- host : parsedUrl . host ,
64
- ...headers ,
65
- }
63
+ headers : headers
66
64
} ;
67
65
}
68
66
69
- var request = interface . request ( options , function ( res ) {
67
+ var request = protocolInterface . request ( internalOptions , function ( res ) {
70
68
var rawData = '' ;
71
69
res . setEncoding ( 'utf8' ) ;
72
70
res . on ( 'data' , function ( chunk ) {
73
71
rawData += chunk ;
74
- } )
72
+ } ) ;
75
73
res . on ( 'end' , function ( ) {
76
74
switch ( res . statusCode ) {
77
75
case 200 : // Success with content returned in response body.
@@ -115,8 +113,8 @@ var httpRequest = function (options) {
115
113
} ) ;
116
114
} ) ;
117
115
118
- if ( options . timeout ) {
119
- request . setTimeout ( options . timeout , function ( ) {
116
+ if ( internalOptions . timeout ) {
117
+ request . setTimeout ( internalOptions . timeout , function ( ) {
120
118
request . abort ( ) ;
121
119
} ) ;
122
120
}
0 commit comments