| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c4a7e05 commit e69b8d2
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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, false) | ||
| 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 | - // Note: arrayBuffer already cloned. | ||
| 322 | - return bytes.buffer | ||
| 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, false) | ||
| 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, false) | ||
| 334 | + return consumeBody(this, parseJSONFromBytes, instance) | ||
| 336 | 335 | }, | |
| 337 | 336 | ||
| 338 | 337 | formData () { | |
@@ -384,16 +383,16 @@ 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, false) | ||
| 386 | + }, instance) | ||
| 388 | 387 | }, | |
| 389 | 388 | ||
| 390 | 389 | bytes () { | |
| 391 | 390 | // The bytes() method steps are to return the result of running consume body | |
| 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.buffer, 0, bytes.byteLength) | ||
| 396 | - }, instance, true) | ||
| 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, shouldClone) { | ||
| 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, shouldClone) | ||
| 450 | + await fullyReadBody(object[kState].body, successSteps, errorSteps) | ||
| 453 | 451 | ||
| 454 | 452 | // 7. Return promise. | |
| 455 | 453 | return promise.promise | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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, shouldClone) { | ||
| 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, shouldClone)) | ||
| 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, shouldClone) { | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "name": "undici", | |
| 3 | - "version": "6.19.1", | ||
| 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 --skipLibCheck test/imports/undici-import.ts", | ||
| 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 install && node ./scripts/platform-shell.js" | ||
| 102 | + "prepare": "husky && node ./scripts/platform-shell.js" | ||
| 103 | 103 | }, | |
| 104 | 104 | "devDependencies": { | |
| 105 | 105 | "@fastify/busboy": "2.1.1", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | /// <reference types="node" /> | |
| 3 | 3 | ||
| 4 | 4 | import { File } from './file' | |
| 5 | - import { SpecIterator, SpecIterableIterator } from './fetch' | ||
| 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. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,15 @@ | |||
| 1 | 1 | import Dispatcher from "./dispatcher"; | |
| 2 | 2 | import RetryHandler from "./retry-handler"; | |
| 3 | 3 | ||
| 4 | - export type DumpInterceptorOpts = { maxSize?: number } | ||
| 5 | - export type RetryInterceptorOpts = RetryHandler.RetryOptions | ||
| 6 | - export type RedirectInterceptorOpts = { maxRedirections?: number } | ||
| 4 | + export default Interceptors; | ||
| 7 | 5 | ||
| 8 | - export declare function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor | ||
| 9 | - export declare function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor | ||
| 10 | - export declare function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor | ||
| 11 | - export declare function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor | ||
| 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,4 @@ | |||
| 1 | - import Agent from './agent' | ||
| 2 | - import buildConnector from './connector'; | ||
| 3 | 1 | import Dispatcher from './dispatcher' | |
| 4 | - import { IncomingHttpHeaders } from './header' | ||
| 5 | 2 | import RetryHandler from './retry-handler' | |
| 6 | 3 | ||
| 7 | 4 | export default RetryAgent | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,9 +55,7 @@ interface WebidlUtil { | |||
| 55 | 55 | V: unknown, | |
| 56 | 56 | bitLength: number, | |
| 57 | 57 | signedness: 'signed' | 'unsigned', | |
| 58 | - opts?: ConvertToIntOpts, | ||
| 59 | - prefix: string, | ||
| 60 | - argument: string | ||
| 58 | + opts?: ConvertToIntOpts | ||
| 61 | 59 | ): number | |
| 62 | 60 | ||
| 63 | 61 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4367,7 +4367,7 @@ var require_util2 = __commonJS({ | |||
| 4367 | 4367 | }); | |
| 4368 | 4368 | } | |
| 4369 | 4369 | __name(iteratorMixin, "iteratorMixin"); | |
| 4370 | - async function fullyReadBody(body, processBody, processBodyError, shouldClone) { | ||
| 4370 | + async function fullyReadBody(body, processBody, processBodyError) { | ||
| 4371 | 4371 | const successSteps = processBody; | |
| 4372 | 4372 | const errorSteps = processBodyError; | |
| 4373 | 4373 | let reader; | |
@@ -4378,7 +4378,7 @@ var require_util2 = __commonJS({ | |||
| 4378 | 4378 | return; | |
| 4379 | 4379 | } | |
| 4380 | 4380 | try { | |
| 4381 | - successSteps(await readAllBytes(reader, shouldClone)); | ||
| 4381 | + successSteps(await readAllBytes(reader)); | ||
| 4382 | 4382 | } catch (e) { | |
| 4383 | 4383 | errorSteps(e); | |
| 4384 | 4384 | } | |
@@ -4405,19 +4405,12 @@ var require_util2 = __commonJS({ | |||
| 4405 | 4405 | return input; | |
| 4406 | 4406 | } | |
| 4407 | 4407 | __name(isomorphicEncode, "isomorphicEncode"); | |
| 4408 | - async function readAllBytes(reader, shouldClone) { | ||
| 4408 | + async function readAllBytes(reader) { | ||
| 4409 | 4409 | const bytes = []; | |
| 4410 | 4410 | let byteLength = 0; | |
| 4411 | 4411 | while (true) { | |
| 4412 | 4412 | const { done, value: chunk } = await reader.read(); | |
| 4413 | 4413 | if (done) { | |
| 4414 | - if (bytes.length === 1) { | ||
| 4415 | - const { buffer, byteOffset, byteLength: byteLength2 } = bytes[0]; | ||
| 4416 | - if (shouldClone === false) { | ||
| 4417 | - return Buffer.from(buffer, byteOffset, byteLength2); | ||
| 4418 | - } | ||
| 4419 | - return Buffer.from(buffer.slice(byteOffset, byteOffset + byteLength2), 0, byteLength2); | ||
| 4420 | - } | ||
| 4421 | 4414 | return Buffer.concat(bytes, byteLength); | |
| 4422 | 4415 | } | |
| 4423 | 4416 | if (!isUint8Array(chunk)) { | |
@@ -5393,18 +5386,18 @@ Content-Type: ${value.type || "application/octet-stream"}\r | |||
| 5393 | 5386 | mimeType = serializeAMimeType(mimeType); | |
| 5394 | 5387 | } | |
| 5395 | 5388 | return new Blob2([bytes], { type: mimeType }); | |
| 5396 | - }, instance, false); | ||
| 5389 | + }, instance); | ||
| 5397 | 5390 | }, | |
| 5398 | 5391 | arrayBuffer() { | |
| 5399 | 5392 | return consumeBody(this, (bytes) => { | |
| 5400 | - return bytes.buffer; | ||
| 5401 | - }, instance, true); | ||
| 5393 | + return new Uint8Array(bytes).buffer; | ||
| 5394 | + }, instance); | ||
| 5402 | 5395 | }, | |
| 5403 | 5396 | text() { | |
| 5404 | - return consumeBody(this, utf8DecodeBytes, instance, false); | ||
| 5397 | + return consumeBody(this, utf8DecodeBytes, instance); | ||
| 5405 | 5398 | }, | |
| 5406 | 5399 | json() { | |
| 5407 | - return consumeBody(this, parseJSONFromBytes, instance, false); | ||
| 5400 | + return consumeBody(this, parseJSONFromBytes, instance); | ||
| 5408 | 5401 | }, | |
| 5409 | 5402 | formData() { | |
| 5410 | 5403 | return consumeBody(this, (value) => { | |
@@ -5433,12 +5426,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r | |||
| 5433 | 5426 | throw new TypeError( | |
| 5434 | 5427 | 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".' | |
| 5435 | 5428 | ); | |
| 5436 | - }, instance, false); | ||
| 5429 | + }, instance); | ||
| 5437 | 5430 | }, | |
| 5438 | 5431 | bytes() { | |
| 5439 | 5432 | return consumeBody(this, (bytes) => { | |
| 5440 | - return new Uint8Array(bytes.buffer, 0, bytes.byteLength); | ||
| 5441 | - }, instance, true); | ||
| 5433 | + return new Uint8Array(bytes); | ||
| 5434 | + }, instance); | ||
| 5442 | 5435 | } | |
| 5443 | 5436 | }; | |
| 5444 | 5437 | return methods; | |
@@ -5448,7 +5441,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r | |||
| 5448 | 5441 | Object.assign(prototype.prototype, bodyMixinMethods(prototype)); | |
| 5449 | 5442 | } | |
| 5450 | 5443 | __name(mixinBody, "mixinBody"); | |
| 5451 | - async function consumeBody(object, convertBytesToJSValue, instance, shouldClone) { | ||
| 5444 | + async function consumeBody(object, convertBytesToJSValue, instance) { | ||
| 5452 | 5445 | webidl.brandCheck(object, instance); | |
| 5453 | 5446 | if (bodyUnusable(object[kState].body)) { | |
| 5454 | 5447 | throw new TypeError("Body is unusable: Body has already been read"); | |
@@ -5467,7 +5460,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r | |||
| 5467 | 5460 | successSteps(Buffer.allocUnsafe(0)); | |
| 5468 | 5461 | return promise.promise; | |
| 5469 | 5462 | } | |
| 5470 | - await fullyReadBody(object[kState].body, successSteps, errorSteps, shouldClone); | ||
| 5463 | + await fullyReadBody(object[kState].body, successSteps, errorSteps); | ||
| 5471 | 5464 | return promise.promise; | |
| 5472 | 5465 | } | |
| 5473 | 5466 | __name(consumeBody, "consumeBody"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments