@@ -22,6 +22,7 @@ const {
2222} = http2 . constants
2323
2424const NODE_VER = process . version . match ( / v ( \d + ) .( \d + ) .( \d + ) (?: - ( .* ) ) / ) . slice ( 1 )
25+ const REQ_OPTIONS = { }
2526
2627if ( NODE_VER [ 0 ] < 9 && ( NODE_VER [ 0 ] !== 8 || NODE_VER [ 1 ] > 4 ) ) {
2728 throw new Error ( `unsupported node version (${ process . version } < 8.5.0)` )
@@ -97,24 +98,23 @@ function impl (req, resOrSocket, headOrNil, {
9798 }
9899 }
99100
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
108107
109108 if ( onReq ) {
110- onReq ( req , options )
109+ onReq ( req , REQ_OPTIONS )
111110 }
112111
113- proxy ( req , resOrSocket , options , onRes , errorHandler )
112+ const proxyReq = http . request ( REQ_OPTIONS )
113+
114+ proxy ( req , resOrSocket , proxyReq , onRes , errorHandler )
114115}
115116
116- function proxy ( req , resOrSocket , options , onRes , errorHandler ) {
117- const proxyReq = http . request ( options )
117+ function proxy ( req , resOrSocket , proxyReq , onRes , errorHandler ) {
118118 const proxyErrorHandler = ProxyErrorHandler . create ( req , proxyReq , errorHandler )
119119
120120 req
0 commit comments