bare-http1 4.0.3 → 4.0.4

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.
@@ -143,12 +143,13 @@ module.exports = class HTTPClientConnection {
143
143
  if (r.length === 0) return this.socket.destroy()
144
144
 
145
145
  const [, statusCode, ...statusMessage] = r[0].split(' ')
146
- if (!statusCode || !statusMessage) return this.socket.destroy()
146
+ if (!statusCode || !statusMessage.length) return this.socket.destroy()
147
147
 
148
148
  const headers = {}
149
149
 
150
150
  for (let i = 1; i < r.length; i++) {
151
- const [name, value] = r[i].split(': ')
151
+ const [name, value] = splitHeader(r[i])
152
+ if (name === null) return this.socket.destroy()
152
153
  headers[name.toLowerCase()] = value
153
154
  }
154
155
 
@@ -262,3 +263,9 @@ module.exports = class HTTPClientConnection {
262
263
  HTTPClientConnection._connections.delete(this.socket)
263
264
  }
264
265
  }
266
+
267
+ function splitHeader(s) {
268
+ const i = s.indexOf(': ')
269
+ if (i === -1) return [null, null]
270
+ return [s.slice(0, i), s.slice(i + 2)]
271
+ }
@@ -145,7 +145,8 @@ module.exports = class HTTPServerConnection {
145
145
  const headers = {}
146
146
 
147
147
  for (let i = 1; i < r.length; i++) {
148
- const [name, value] = r[i].split(': ')
148
+ const [name, value] = splitHeader(r[i])
149
+ if (name === null) return this.socket.destroy()
149
150
  headers[name.toLowerCase()] = value
150
151
  }
151
152
 
@@ -270,3 +271,9 @@ module.exports = class HTTPServerConnection {
270
271
  }
271
272
 
272
273
  function noop() {}
274
+
275
+ function splitHeader(s) {
276
+ const i = s.indexOf(': ')
277
+ if (i === -1) return [null, null]
278
+ return [s.slice(0, i), s.slice(i + 2)]
279
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-http1",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Native HTTP/1 library for JavaScript",
5
5
  "exports": {
6
6
  "./package": "./package.json",