bare-http1 4.0.4 → 4.1.0
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.d.ts +1 -0
- package/index.js +1 -0
- package/lib/client-request.js +7 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.ClientConnection = require('./lib/client-connection')
|
|
|
14
14
|
exports.constants = require('./lib/constants')
|
|
15
15
|
exports.errors = require('./lib/errors')
|
|
16
16
|
|
|
17
|
+
exports.METHODS = Object.values(exports.constants.method) // For Node.js compatibility
|
|
17
18
|
exports.STATUS_CODES = exports.constants.status // For Node.js compatibility
|
|
18
19
|
|
|
19
20
|
exports.createServer = function createServer(opts, onrequest) {
|
package/lib/client-request.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const HTTPAgent = require('./agent')
|
|
2
2
|
const HTTPOutgoingMessage = require('./outgoing-message')
|
|
3
3
|
|
|
4
|
+
const CHUNK_DELIMITER = Buffer.from('\r\n')
|
|
5
|
+
const CHUNK_TERMINATOR = Buffer.from('0\r\n\r\n')
|
|
6
|
+
|
|
4
7
|
module.exports = class HTTPClientRequest extends HTTPOutgoingMessage {
|
|
5
8
|
constructor(opts = {}, onresponse = null) {
|
|
6
9
|
if (typeof opts === 'function') {
|
|
@@ -62,9 +65,10 @@ module.exports = class HTTPClientRequest extends HTTPOutgoingMessage {
|
|
|
62
65
|
|
|
63
66
|
if (this._chunked) {
|
|
64
67
|
data = Buffer.concat([
|
|
65
|
-
Buffer.from(
|
|
68
|
+
Buffer.from(data.byteLength.toString(16)),
|
|
69
|
+
CHUNK_DELIMITER,
|
|
66
70
|
data,
|
|
67
|
-
|
|
71
|
+
CHUNK_DELIMITER
|
|
68
72
|
])
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -75,7 +79,7 @@ module.exports = class HTTPClientRequest extends HTTPOutgoingMessage {
|
|
|
75
79
|
_final(cb) {
|
|
76
80
|
if (this.headersSent === false) this.flushHeaders()
|
|
77
81
|
|
|
78
|
-
if (this._chunked) this.socket.write(
|
|
82
|
+
if (this._chunked) this.socket.write(CHUNK_TERMINATOR)
|
|
79
83
|
|
|
80
84
|
this._pendingFinal = cb
|
|
81
85
|
}
|