bare-http1 3.6.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client-request.js +9 -6
- package/package.json +1 -1
package/lib/client-request.js
CHANGED
|
@@ -9,7 +9,13 @@ module.exports = class HTTPClientRequest extends HTTPOutgoingMessage {
|
|
|
9
9
|
opts = {}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
opts = opts ? { ...opts } : {}
|
|
13
|
+
|
|
12
14
|
const agent = opts.agent === false ? new HTTPAgent() : opts.agent || HTTPAgent.global
|
|
15
|
+
const method = opts.method || 'GET'
|
|
16
|
+
const path = opts.path || '/'
|
|
17
|
+
const host = opts.host = opts.host || 'localhost'
|
|
18
|
+
const port = opts.port = opts.port || 80
|
|
13
19
|
|
|
14
20
|
const {
|
|
15
21
|
connection = new HTTPClientConnection(agent.createConnection(opts), opts)
|
|
@@ -19,15 +25,12 @@ module.exports = class HTTPClientRequest extends HTTPOutgoingMessage {
|
|
|
19
25
|
|
|
20
26
|
connection.req = this
|
|
21
27
|
|
|
22
|
-
this.method =
|
|
23
|
-
this.path =
|
|
24
|
-
const host = opts.host || 'localhost'
|
|
25
|
-
const port = opts.port || 80
|
|
26
|
-
|
|
28
|
+
this.method = method
|
|
29
|
+
this.path = path
|
|
27
30
|
this.headers = { host: host + ':' + port, ...opts.headers }
|
|
28
31
|
|
|
29
32
|
this._connection = connection
|
|
30
|
-
this._chunked =
|
|
33
|
+
this._chunked = method !== 'GET' && method !== 'HEAD'
|
|
31
34
|
|
|
32
35
|
this._pendingFinal = null
|
|
33
36
|
|