@@ -309,7 +309,7 @@ function bodyMixinMethods (instance) {
309309 // Return a Blob whose contents are bytes and type attribute
310310 // is mimeType.
311311 return new Blob ( [ bytes ] , { type : mimeType } )
312- } , instance , false )
312+ } , instance )
313313 } ,
314314
315315 arrayBuffer ( ) {
@@ -318,21 +318,20 @@ function bodyMixinMethods (instance) {
318318 // given a byte sequence bytes: return a new ArrayBuffer
319319 // whose contents are bytes.
320320 return consumeBody ( this , ( bytes ) => {
321- // Note: arrayBuffer already cloned.
322- return bytes . buffer
323- } , instance , true )
321+ return new Uint8Array ( bytes ) . buffer
322+ } , instance )
324323 } ,
325324
326325 text ( ) {
327326 // The text() method steps are to return the result of running
328327 // consume body with this and UTF-8 decode.
329- return consumeBody ( this , utf8DecodeBytes , instance , false )
328+ return consumeBody ( this , utf8DecodeBytes , instance )
330329 } ,
331330
332331 json ( ) {
333332 // The json() method steps are to return the result of running
334333 // consume body with this and parse JSON from bytes.
335- return consumeBody ( this , parseJSONFromBytes , instance , false )
334+ return consumeBody ( this , parseJSONFromBytes , instance )
336335 } ,
337336
338337 formData ( ) {
@@ -384,16 +383,16 @@ function bodyMixinMethods (instance) {
384383 throw new TypeError (
385384 'Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".'
386385 )
387- } , instance , false )
386+ } , instance )
388387 } ,
389388
390389 bytes ( ) {
391390 // The bytes() method steps are to return the result of running consume body
392391 // with this and the following step given a byte sequence bytes: return the
393392 // result of creating a Uint8Array from bytes in this’s relevant realm.
394393 return consumeBody ( this , ( bytes ) => {
395- return new Uint8Array ( bytes . buffer , 0 , bytes . byteLength )
396- } , instance , true )
394+ return new Uint8Array ( bytes )
395+ } , instance )
397396 }
398397 }
399398
@@ -409,9 +408,8 @@ function mixinBody (prototype) {
409408 * @param {Response|Request } object
410409 * @param {(value: unknown) => unknown } convertBytesToJSValue
411410 * @param {Response|Request } instance
412- * @param {boolean } [shouldClone]
413411 */
414- async function consumeBody ( object , convertBytesToJSValue , instance , shouldClone ) {
412+ async function consumeBody ( object , convertBytesToJSValue , instance ) {
415413 webidl . brandCheck ( object , instance )
416414
417415 // 1. If object is unusable, then return a promise rejected
@@ -449,7 +447,7 @@ async function consumeBody (object, convertBytesToJSValue, instance, shouldClone
449447
450448 // 6. Otherwise, fully read object’s body given successSteps,
451449 // errorSteps, and object’s relevant global object.
452- await fullyReadBody ( object [ kState ] . body , successSteps , errorSteps , shouldClone )
450+ await fullyReadBody ( object [ kState ] . body , successSteps , errorSteps )
453451
454452 // 7. Return promise.
455453 return promise . promise
0 commit comments