File tree 3 files changed +16
-11
lines changed
3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 3
3
const util = require ( '../../core/util' )
4
4
const { finished } = require ( 'stream' )
5
5
const { ReadableStream, CountQueuingStrategy } = require ( 'stream/web' )
6
- const { AbortError, InvalidArgumentError } = require ( '../../core/errors' )
6
+ const { AbortError } = require ( '../../core/errors' )
7
7
8
8
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
9
9
function extractBody ( body ) {
@@ -26,8 +26,13 @@ function extractBody (body) {
26
26
} else if (
27
27
body instanceof ArrayBuffer ||
28
28
ArrayBuffer . isView ( body ) ||
29
- util . isBuffer ( body )
29
+ util . isBuffer ( body ) ||
30
+ body instanceof DataView
30
31
) {
32
+ if ( body instanceof DataView ) {
33
+ // TODO: Blob doesn't seem to work with DataView?
34
+ body = body . buffer
35
+ }
31
36
return [ {
32
37
source : body
33
38
} , null ]
Original file line number Diff line number Diff line change 1
- // import chai from 'chai'
2
- // import { fetch } from '../../index.js'
1
+ // const chai = require( 'chai')
2
+ // const { fetch } = require( '../../index.js')
3
3
4
4
// const { expect } = chai
5
5
Original file line number Diff line number Diff line change @@ -187,13 +187,13 @@ describe('Response', () => {
187
187
} )
188
188
} )
189
189
190
- // it('should support DataView as body', () => {
191
- // const encoder = new TextEncoder()
192
- // const res = new Response(new DataView(encoder.encode('a=1').buffer))
193
- // return res.text().then(result => {
194
- // expect(result).to.equal('a=1')
195
- // })
196
- // })
190
+ it ( 'should support DataView as body' , ( ) => {
191
+ const encoder = new TextEncoder ( )
192
+ const res = new Response ( new DataView ( encoder . encode ( 'a=1' ) . buffer ) )
193
+ return res . text ( ) . then ( result => {
194
+ expect ( result ) . to . equal ( 'a=1' )
195
+ } )
196
+ } )
197
197
198
198
it ( 'should default to null as body' , ( ) => {
199
199
const res = new Response ( )
You can’t perform that action at this time.
0 commit comments