bare-http1 4.5.1 → 4.5.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/index.d.ts CHANGED
@@ -179,7 +179,7 @@ export interface HTTPServerConnectionOptions {
179
179
 
180
180
  export interface HTTPServerConnection {
181
181
  readonly server: HTTPServer
182
- readonly socket: TCPSocket
182
+ readonly socket: TCPSocket | null
183
183
 
184
184
  readonly req: HTTPIncomingMessage | null
185
185
  readonly res: HTTPServerResponse | null
@@ -228,7 +228,7 @@ export interface HTTPClientConnectionOptions {
228
228
  }
229
229
 
230
230
  export interface HTTPClientConnection {
231
- readonly socket: TCPSocket
231
+ readonly socket: TCPSocket | null
232
232
 
233
233
  readonly req: HTTPClientRequest | null
234
234
  readonly res: HTTPIncomingMessage | null
@@ -1,3 +1,4 @@
1
+ const { isFinishing } = require('bare-stream')
1
2
  const HTTPOutgoingMessage = require('./outgoing-message')
2
3
  const constants = require('./constants')
3
4
 
@@ -15,7 +16,6 @@ module.exports = class HTTPServerResponse extends HTTPOutgoingMessage {
15
16
 
16
17
  this._chunked = true
17
18
  this._close = close
18
- this._finishing = false
19
19
  this._onlyHeaders = req.method === 'HEAD'
20
20
 
21
21
  this._pendingWrite = null
@@ -33,12 +33,6 @@ module.exports = class HTTPServerResponse extends HTTPOutgoingMessage {
33
33
  return this._statusMessage
34
34
  }
35
35
 
36
- end(data) {
37
- this._finishing = true
38
-
39
- return super.end(data)
40
- }
41
-
42
36
  writeHead(statusCode, statusMessage = null, headers = {}) {
43
37
  if (typeof statusMessage === 'object' && statusMessage !== null) {
44
38
  headers = statusMessage
@@ -78,7 +72,7 @@ module.exports = class HTTPServerResponse extends HTTPOutgoingMessage {
78
72
 
79
73
  _write(data, encoding, cb) {
80
74
  if (this._headersSent === false) {
81
- if (this._finishing) {
75
+ if (isFinishing(this)) {
82
76
  this.setHeader(
83
77
  'Content-Length',
84
78
  (data.byteLength + this._writableState.buffered).toString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-http1",
3
- "version": "4.5.1",
3
+ "version": "4.5.3",
4
4
  "description": "Native HTTP/1 library for JavaScript",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "bare-events": "^2.6.0",
40
40
  "bare-http-parser": "^1.1.1",
41
- "bare-stream": "^2.3.0",
41
+ "bare-stream": "^2.10.0",
42
42
  "bare-tcp": "^2.2.0"
43
43
  },
44
44
  "devDependencies": {