Skip to content

Commit 7334d8c

Browse files
committed
fixup: tests
1 parent ba51fe5 commit 7334d8c

4 files changed

Lines changed: 396 additions & 6 deletions

File tree

docs/api/Dispatcher.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ The `RequestOptions.method` property should not be value `'CONNECT'`.
418418

419419
* **statusCode** `number`
420420
* **headers** `http.IncomingHttpHeaders`
421-
* **body** `stream.Readable`
421+
* **body** `stream.Readable` which also implements [the body mixin from the Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
422422
* **trailers** `Record<string, string>` - This object starts out
423423
as empty and will be mutated to contain trailers after `body` has emitted `'end'`.
424424
* **opaque** `unknown`

lib/api/readable.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ module.exports = class BodyReadable extends Readable {
4949
return super.on(ev, ...args)
5050
}
5151

52+
addListener (ev, ...args) {
53+
if (ev === 'data' || ev === 'readable') {
54+
this[kReading] = true
55+
}
56+
return super.addListener(ev, ...args)
57+
}
58+
5259
push (chunk, encoding) {
5360
if (this[kConsume] && chunk !== null && !this[kReading]) {
5461
// Fast path.
@@ -90,6 +97,7 @@ module.exports = class BodyReadable extends Readable {
9097
return isDisturbed(this)
9198
}
9299

100+
// https://fetch.spec.whatwg.org/#dom-body-body
93101
get body () {
94102
if (this[kConsume] && this[kConsume].type === kWebStreamType) {
95103
return this[kConsume].stream
@@ -125,20 +133,16 @@ function isUnusable (self) {
125133

126134
async function consume (parent, type) {
127135
if (isUnusable(parent)) {
128-
// eslint-disable-next-line no-restricted-syntax
129136
throw new TypeError('unusable')
130137
}
131138

132139
if (parent[kConsume]) {
133-
// TODO: Should multiple consume in same tick be possible?
134-
// eslint-disable-next-line no-restricted-syntax
135140
throw new TypeError('unusable')
136141
}
137142

138143
if (type === kWebStreamType) {
139144
const consume = parent[kConsume] = {
140145
type,
141-
// TODO: Optimized implementation for web streams.
142146
stream: Readable.toWeb(parent)
143147
}
144148

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "undici",
3-
"version": "4.3.0",
3+
"version": "4.2.2",
44
"description": "An HTTP/1.1 client, written from scratch for Node.js",
55
"homepage": "https://undici.nodejs.org",
66
"bugs": {

0 commit comments

Comments
 (0)