Skip to content

Commit 4143a9b

Browse files
committed
Refactor Request class to simplify URL handling in send method
1 parent a8337f0 commit 4143a9b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/node/NodeHttpStack.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,8 @@ class Request implements HttpRequest {
8888
}
8989

9090
return new Promise((resolve, reject) => {
91-
const parsedUrl = new URL(this._url)
91+
const url = new URL(this._url)
9292
const options = {
93-
protocol: parsedUrl.protocol,
94-
hostname: parsedUrl.hostname,
95-
port: parsedUrl.port,
96-
path: parsedUrl.pathname + parsedUrl.search,
9793
...this._requestOptions,
9894

9995
method: this._method,
@@ -110,8 +106,8 @@ class Request implements HttpRequest {
110106
options.headers['Content-Length'] = body.size
111107
}
112108

113-
const httpModule = options.protocol === 'https:' ? https : http
114-
this._request = httpModule.request(options)
109+
const httpModule = url.protocol === 'https:' ? https : http
110+
this._request = httpModule.request(url, options)
115111
const req = this._request
116112
req.on('response', (res) => {
117113
const resChunks: Buffer[] = []

0 commit comments

Comments
 (0)