undici 6.19.1 → 6.19.2
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/lib/web/fetch/body.js +10 -12
- package/lib/web/fetch/util.js +3 -11
- package/package.json +3 -3
- package/types/formdata.d.ts +1 -1
- package/types/index.d.ts +2 -6
- package/types/interceptors.d.ts +11 -7
- package/types/retry-agent.d.ts +0 -3
- package/types/webidl.d.ts +1 -3
package/lib/web/fetch/body.js
CHANGED
|
@@ -309,7 +309,7 @@ function bodyMixinMethods (instance) {
|
|
|
309
309
|
// Return a Blob whose contents are bytes and type attribute
|
|
310
310
|
// is mimeType.
|
|
311
311
|
return new Blob([bytes], { type: mimeType })
|
|
312
|
-
}, instance
|
|
312
|
+
}, instance)
|
|
313
313
|
},
|
|
314
314
|
|
|
315
315
|
arrayBuffer () {
|
|
@@ -318,21 +318,20 @@ function bodyMixinMethods (instance) {
|
|
|
318
318
|
// given a byte sequence bytes: return a new ArrayBuffer
|
|
319
319
|
// whose contents are bytes.
|
|
320
320
|
return consumeBody(this, (bytes) => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}, instance, true)
|
|
321
|
+
return new Uint8Array(bytes).buffer
|
|
322
|
+
}, instance)
|
|
324
323
|
},
|
|
325
324
|
|
|
326
325
|
text () {
|
|
327
326
|
// The text() method steps are to return the result of running
|
|
328
327
|
// consume body with this and UTF-8 decode.
|
|
329
|
-
return consumeBody(this, utf8DecodeBytes, instance
|
|
328
|
+
return consumeBody(this, utf8DecodeBytes, instance)
|
|
330
329
|
},
|
|
331
330
|
|
|
332
331
|
json () {
|
|
333
332
|
// The json() method steps are to return the result of running
|
|
334
333
|
// consume body with this and parse JSON from bytes.
|
|
335
|
-
return consumeBody(this, parseJSONFromBytes, instance
|
|
334
|
+
return consumeBody(this, parseJSONFromBytes, instance)
|
|
336
335
|
},
|
|
337
336
|
|
|
338
337
|
formData () {
|
|
@@ -384,7 +383,7 @@ function bodyMixinMethods (instance) {
|
|
|
384
383
|
throw new TypeError(
|
|
385
384
|
'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
|
|
386
385
|
)
|
|
387
|
-
}, instance
|
|
386
|
+
}, instance)
|
|
388
387
|
},
|
|
389
388
|
|
|
390
389
|
bytes () {
|
|
@@ -392,8 +391,8 @@ function bodyMixinMethods (instance) {
|
|
|
392
391
|
// with this and the following step given a byte sequence bytes: return the
|
|
393
392
|
// result of creating a Uint8Array from bytes in this’s relevant realm.
|
|
394
393
|
return consumeBody(this, (bytes) => {
|
|
395
|
-
return new Uint8Array(bytes
|
|
396
|
-
}, instance
|
|
394
|
+
return new Uint8Array(bytes)
|
|
395
|
+
}, instance)
|
|
397
396
|
}
|
|
398
397
|
}
|
|
399
398
|
|
|
@@ -409,9 +408,8 @@ function mixinBody (prototype) {
|
|
|
409
408
|
* @param {Response|Request} object
|
|
410
409
|
* @param {(value: unknown) => unknown} convertBytesToJSValue
|
|
411
410
|
* @param {Response|Request} instance
|
|
412
|
-
* @param {boolean} [shouldClone]
|
|
413
411
|
*/
|
|
414
|
-
async function consumeBody (object, convertBytesToJSValue, instance
|
|
412
|
+
async function consumeBody (object, convertBytesToJSValue, instance) {
|
|
415
413
|
webidl.brandCheck(object, instance)
|
|
416
414
|
|
|
417
415
|
// 1. If object is unusable, then return a promise rejected
|
|
@@ -449,7 +447,7 @@ async function consumeBody (object, convertBytesToJSValue, instance, shouldClone
|
|
|
449
447
|
|
|
450
448
|
// 6. Otherwise, fully read object’s body given successSteps,
|
|
451
449
|
// errorSteps, and object’s relevant global object.
|
|
452
|
-
await fullyReadBody(object[kState].body, successSteps, errorSteps
|
|
450
|
+
await fullyReadBody(object[kState].body, successSteps, errorSteps)
|
|
453
451
|
|
|
454
452
|
// 7. Return promise.
|
|
455
453
|
return promise.promise
|
package/lib/web/fetch/util.js
CHANGED
|
@@ -1029,7 +1029,7 @@ function iteratorMixin (name, object, kInternalIterator, keyIndex = 0, valueInde
|
|
|
1029
1029
|
/**
|
|
1030
1030
|
* @see https://fetch.spec.whatwg.org/#body-fully-read
|
|
1031
1031
|
*/
|
|
1032
|
-
async function fullyReadBody (body, processBody, processBodyError
|
|
1032
|
+
async function fullyReadBody (body, processBody, processBodyError) {
|
|
1033
1033
|
// 1. If taskDestination is null, then set taskDestination to
|
|
1034
1034
|
// the result of starting a new parallel queue.
|
|
1035
1035
|
|
|
@@ -1055,7 +1055,7 @@ async function fullyReadBody (body, processBody, processBodyError, shouldClone)
|
|
|
1055
1055
|
|
|
1056
1056
|
// 5. Read all bytes from reader, given successSteps and errorSteps.
|
|
1057
1057
|
try {
|
|
1058
|
-
successSteps(await readAllBytes(reader
|
|
1058
|
+
successSteps(await readAllBytes(reader))
|
|
1059
1059
|
} catch (e) {
|
|
1060
1060
|
errorSteps(e)
|
|
1061
1061
|
}
|
|
@@ -1103,9 +1103,8 @@ function isomorphicEncode (input) {
|
|
|
1103
1103
|
* @see https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes
|
|
1104
1104
|
* @see https://streams.spec.whatwg.org/#read-loop
|
|
1105
1105
|
* @param {ReadableStreamDefaultReader} reader
|
|
1106
|
-
* @param {boolean} [shouldClone]
|
|
1107
1106
|
*/
|
|
1108
|
-
async function readAllBytes (reader
|
|
1107
|
+
async function readAllBytes (reader) {
|
|
1109
1108
|
const bytes = []
|
|
1110
1109
|
let byteLength = 0
|
|
1111
1110
|
|
|
@@ -1114,13 +1113,6 @@ async function readAllBytes (reader, shouldClone) {
|
|
|
1114
1113
|
|
|
1115
1114
|
if (done) {
|
|
1116
1115
|
// 1. Call successSteps with bytes.
|
|
1117
|
-
if (bytes.length === 1) {
|
|
1118
|
-
const { buffer, byteOffset, byteLength } = bytes[0]
|
|
1119
|
-
if (shouldClone === false) {
|
|
1120
|
-
return Buffer.from(buffer, byteOffset, byteLength)
|
|
1121
|
-
}
|
|
1122
|
-
return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength), 0, byteLength)
|
|
1123
|
-
}
|
|
1124
1116
|
return Buffer.concat(bytes, byteLength)
|
|
1125
1117
|
}
|
|
1126
1118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undici",
|
|
3
|
-
"version": "6.19.
|
|
3
|
+
"version": "6.19.2",
|
|
4
4
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|
5
5
|
"homepage": "https://undici.nodejs.org",
|
|
6
6
|
"bugs": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"test:node-test": "borp -p \"test/node-test/**/*.js\"",
|
|
86
86
|
"test:tdd": "borp --expose-gc -p \"test/*.js\"",
|
|
87
87
|
"test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
|
|
88
|
-
"test:typescript": "tsd && tsc
|
|
88
|
+
"test:typescript": "tsd && tsc test/imports/undici-import.ts --typeRoots ./types && tsc ./types/*.d.ts --noEmit --typeRoots ./types",
|
|
89
89
|
"test:webidl": "borp -p \"test/webidl/*.js\"",
|
|
90
90
|
"test:websocket": "borp -p \"test/websocket/*.js\"",
|
|
91
91
|
"test:websocket:autobahn": "node test/autobahn/client.js",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"coverage:report:ci": "c8 report",
|
|
100
100
|
"bench": "echo \"Error: Benchmarks have been moved to '/benchmarks'\" && exit 1",
|
|
101
101
|
"serve:website": "echo \"Error: Documentation has been moved to '/docs'\" && exit 1",
|
|
102
|
-
"prepare": "husky
|
|
102
|
+
"prepare": "husky && node ./scripts/platform-shell.js"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@fastify/busboy": "2.1.1",
|
package/types/formdata.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
|
|
4
4
|
import { File } from './file'
|
|
5
|
-
import {
|
|
5
|
+
import { SpecIterableIterator } from './fetch'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
|
package/types/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ declare namespace Undici {
|
|
|
42
42
|
var RedirectHandler: typeof import ('./handlers').RedirectHandler
|
|
43
43
|
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
|
|
44
44
|
var RetryHandler: typeof import ('./retry-handler').default
|
|
45
|
-
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
|
|
45
|
+
var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
|
|
46
46
|
var BalancedPool: typeof import('./balanced-pool').default;
|
|
47
47
|
var Client: typeof import('./client').default;
|
|
48
48
|
var buildConnector: typeof import('./connector').default;
|
|
@@ -67,9 +67,5 @@ declare namespace Undici {
|
|
|
67
67
|
var File: typeof import('./file').File;
|
|
68
68
|
var FileReader: typeof import('./filereader').FileReader;
|
|
69
69
|
var caches: typeof import('./cache').caches;
|
|
70
|
-
var interceptors:
|
|
71
|
-
dump: typeof import('./interceptors').dump;
|
|
72
|
-
retry: typeof import('./interceptors').retry;
|
|
73
|
-
redirect: typeof import('./interceptors').redirect;
|
|
74
|
-
}
|
|
70
|
+
var interceptors: typeof import('./interceptors').default;
|
|
75
71
|
}
|
package/types/interceptors.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import Dispatcher from "./dispatcher";
|
|
2
2
|
import RetryHandler from "./retry-handler";
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
export type RetryInterceptorOpts = RetryHandler.RetryOptions
|
|
6
|
-
export type RedirectInterceptorOpts = { maxRedirections?: number }
|
|
4
|
+
export default Interceptors;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
6
|
+
declare namespace Interceptors {
|
|
7
|
+
export type DumpInterceptorOpts = { maxSize?: number }
|
|
8
|
+
export type RetryInterceptorOpts = RetryHandler.RetryOptions
|
|
9
|
+
export type RedirectInterceptorOpts = { maxRedirections?: number }
|
|
10
|
+
|
|
11
|
+
export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
12
|
+
export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
13
|
+
export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
14
|
+
export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
15
|
+
}
|
package/types/retry-agent.d.ts
CHANGED