undici
Advanced tools
Comparing version 5.25.1 to 5.25.2
@@ -171,3 +171,3 @@ 'use strict' | ||
const state = body._readableState | ||
return state && state.ended === true && Number.isFinite(state.length) | ||
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) | ||
? state.length | ||
@@ -174,0 +174,0 @@ : null |
'use strict' | ||
const { randomBytes, createHash } = require('crypto') | ||
const diagnosticsChannel = require('diagnostics_channel') | ||
@@ -25,2 +24,10 @@ const { uid, states } = require('./constants') | ||
/** @type {import('crypto')} */ | ||
let crypto | ||
try { | ||
crypto = require('crypto') | ||
} catch { | ||
} | ||
/** | ||
@@ -70,3 +77,3 @@ * @see https://websockets.spec.whatwg.org/#concept-websocket-establish | ||
// isomorphic encoded. | ||
const keyValue = randomBytes(16).toString('base64') | ||
const keyValue = crypto.randomBytes(16).toString('base64') | ||
@@ -153,3 +160,3 @@ // 6. Append (`Sec-WebSocket-Key`, keyValue) to request’s | ||
const secWSAccept = response.headersList.get('Sec-WebSocket-Accept') | ||
const digest = createHash('sha1').update(keyValue + uid).digest('base64') | ||
const digest = crypto.createHash('sha1').update(keyValue + uid).digest('base64') | ||
if (secWSAccept !== digest) { | ||
@@ -156,0 +163,0 @@ failWebsocketConnection(ws, 'Incorrect hash received in Sec-WebSocket-Accept header.') |
'use strict' | ||
const { randomBytes } = require('crypto') | ||
const { maxUnsigned16Bit } = require('./constants') | ||
/** @type {import('crypto')} */ | ||
let crypto | ||
try { | ||
crypto = require('crypto') | ||
} catch { | ||
} | ||
class WebsocketFrameSend { | ||
@@ -12,3 +19,3 @@ /** | ||
this.frameData = data | ||
this.maskKey = randomBytes(4) | ||
this.maskKey = crypto.randomBytes(4) | ||
} | ||
@@ -15,0 +22,0 @@ |
{ | ||
"name": "undici", | ||
"version": "5.25.1", | ||
"version": "5.25.2", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org", |
@@ -439,2 +439,3 @@ # undici | ||
* [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag> | ||
* [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf> | ||
@@ -441,0 +442,0 @@ ## License |
{ | ||
"name": "undici-types", | ||
"version": "5.24.0", | ||
"version": "5.25.1", | ||
"description": "A stand-alone types package for Undici", | ||
@@ -55,2 +55,2 @@ "homepage": "https://undici.nodejs.org", | ||
] | ||
} | ||
} |
1144659
19923
444