Comparing version 4.10.4 to 4.11.0
@@ -439,2 +439,6 @@ # Dispatcher | ||
`body` contains the following additional extentions: | ||
- `dump({ limit: Integer })`, dump the response by reading up to `limit` bytes without killing the socket (optional) - Default: 262144. | ||
#### Example 1 - Basic GET Request | ||
@@ -441,0 +445,0 @@ |
@@ -147,2 +147,16 @@ // Ported from https://github.com/nodejs/undici/pull/907 | ||
} | ||
async dump(opts) { | ||
let limit = opts && Number.isFinite(opts.limit) ? opts.limit : 262144 | ||
try { | ||
for await (const chunk of this) { | ||
limit -= Buffer.byteLength(chunk) | ||
if (limit < 0) { | ||
return | ||
} | ||
} | ||
} catch { | ||
// Do nothing... | ||
} | ||
} | ||
} | ||
@@ -223,5 +237,5 @@ | ||
if (type === 'text') { | ||
resolve(body.join('')) | ||
resolve(Buffer.concat(body)) | ||
} else if (type === 'json') { | ||
resolve(JSON.parse(body.join(''))) | ||
resolve(JSON.parse(Buffer.concat(body))) | ||
} else if (type === 'arrayBuffer') { | ||
@@ -228,0 +242,0 @@ const dst = new Uint8Array(length) |
{ | ||
"name": "undici", | ||
"version": "4.10.4", | ||
"version": "4.11.0", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://undici.nodejs.org", |
640407
10169