@@ -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
0 commit comments