File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ function consumeBody() {
206
206
207
207
// body is buffer
208
208
if ( Object . prototype . toString . call ( this . body ) === '[object ArrayBuffer]' ) {
209
- return Body . Promise . resolve ( this . body ) ;
209
+ return Body . Promise . resolve ( Buffer . from ( this . body ) ) ;
210
210
}
211
211
212
212
// istanbul ignore if: should never happen
Original file line number Diff line number Diff line change @@ -1771,6 +1771,13 @@ describe('Response', function () {
1771
1771
} ) ;
1772
1772
} ) ;
1773
1773
1774
+ it ( 'should support ArrayBuffer as body' , function ( ) {
1775
+ const res = new Response ( stringToArrayBuffer ( 'a=1' ) ) ;
1776
+ return res . text ( ) . then ( result => {
1777
+ expect ( result ) . to . equal ( 'a=1' ) ;
1778
+ } ) ;
1779
+ } ) ;
1780
+
1774
1781
it ( 'should support blob as body' , function ( ) {
1775
1782
const res = new Response ( new Blob ( [ 'a=1' ] ) ) ;
1776
1783
return res . text ( ) . then ( result => {
@@ -1973,6 +1980,16 @@ describe('Request', function () {
1973
1980
expect ( results [ 1 ] ) . to . equal ( 'a=1' ) ;
1974
1981
} ) ;
1975
1982
} ) ;
1983
+
1984
+ it ( 'should support ArrayBuffer as body' , function ( ) {
1985
+ const req = new Request ( '' , {
1986
+ method : 'POST' ,
1987
+ body : stringToArrayBuffer ( 'a=1' )
1988
+ } ) ;
1989
+ return req . text ( ) . then ( result => {
1990
+ expect ( result ) . to . equal ( 'a=1' ) ;
1991
+ } ) ;
1992
+ } ) ;
1976
1993
} ) ;
1977
1994
1978
1995
function streamToPromise ( stream , dataHandler ) {
You can’t perform that action at this time.
0 commit comments