@@ -22,6 +22,7 @@ const {
22
22
} = http2 . constants
23
23
24
24
const NODE_VER = process . version . match ( / v ( \d + ) .( \d + ) .( \d + ) (?: - ( .* ) ) / ) . slice ( 1 )
25
+ const REQ_OPTIONS = { }
25
26
26
27
if ( NODE_VER [ 0 ] < 9 && ( NODE_VER [ 0 ] !== 8 || NODE_VER [ 1 ] > 4 ) ) {
27
28
throw new Error ( `unsupported node version (${ process . version } < 8.5.0)` )
@@ -97,24 +98,23 @@ function impl (req, resOrSocket, headOrNil, {
97
98
}
98
99
}
99
100
100
- const options = {
101
- method : req . method ,
102
- hostname,
103
- port,
104
- path : req . url ,
105
- headers,
106
- timeout : proxyTimeout
107
- }
101
+ REQ_OPTIONS . method = req . method
102
+ REQ_OPTIONS . hostname = hostname
103
+ REQ_OPTIONS . port = port
104
+ REQ_OPTIONS . path = req . url
105
+ REQ_OPTIONS . headers = headers
106
+ REQ_OPTIONS . timeout = proxyTimeout
108
107
109
108
if ( onReq ) {
110
- onReq ( req , options )
109
+ onReq ( req , REQ_OPTIONS )
111
110
}
112
111
113
- proxy ( req , resOrSocket , options , onRes , errorHandler )
112
+ const proxyReq = http . request ( REQ_OPTIONS )
113
+
114
+ proxy ( req , resOrSocket , proxyReq , onRes , errorHandler )
114
115
}
115
116
116
- function proxy ( req , resOrSocket , options , onRes , errorHandler ) {
117
- const proxyReq = http . request ( options )
117
+ function proxy ( req , resOrSocket , proxyReq , onRes , errorHandler ) {
118
118
const proxyErrorHandler = ProxyErrorHandler . create ( req , proxyReq , errorHandler )
119
119
120
120
req
0 commit comments