bare-http1 3.6.0 → 3.6.2
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/index.js +4 -4
- package/lib/client-request.js +8 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -44,10 +44,10 @@ exports.request = function request (url, opts, onresponse) {
|
|
|
44
44
|
function defaultPort (url) {
|
|
45
45
|
switch (url.protocol) {
|
|
46
46
|
case 'ftp:': return 21
|
|
47
|
-
case 'http':
|
|
48
|
-
case 'ws': return 80
|
|
49
|
-
case 'https':
|
|
50
|
-
case 'wss': return 443
|
|
47
|
+
case 'http:':
|
|
48
|
+
case 'ws:': return 80
|
|
49
|
+
case 'https:':
|
|
50
|
+
case 'wss:': return 443
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return null
|
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,11 +25,8 @@ 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
|