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.
@@ -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 = opts.method || 'GET'
23
- this.path = opts.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 = true
33
+ this._chunked = method !== 'GET' && method !== 'HEAD'
31
34
 
32
35
  this._pendingFinal = null
33
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-http1",
3
- "version": "3.6.1",
3
+ "version": "3.6.3",
4
4
  "description": "Native HTTP/1 library for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",