This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 4 files changed +18
-1
lines changed
4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 64
64
"isWindow" : false ,
65
65
"isScope" : false ,
66
66
"isFile" : false ,
67
+ "isBlob" : false ,
67
68
"isBoolean" : false ,
68
69
"trim" : false ,
69
70
"isElement" : false ,
Original file line number Diff line number Diff line change 45
45
-isWindow,
46
46
-isScope,
47
47
-isFile,
48
+ -isBlob,
48
49
-isBoolean,
49
50
-trim,
50
51
-isElement,
@@ -566,6 +567,11 @@ function isFile(obj) {
566
567
}
567
568
568
569
570
+ function isBlob ( obj ) {
571
+ return toString . call ( obj ) === '[object Blob]' ;
572
+ }
573
+
574
+
569
575
function isBoolean ( value ) {
570
576
return typeof value === 'boolean' ;
571
577
}
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ function $HttpProvider() {
103
103
104
104
// transform outgoing request data
105
105
transformRequest : [ function ( d ) {
106
- return isObject ( d ) && ! isFile ( d ) ? toJson ( d ) : d ;
106
+ return isObject ( d ) && ! isFile ( d ) && ! isBlob ( d ) ? toJson ( d ) : d ;
107
107
} ] ,
108
108
109
109
// default headers
Original file line number Diff line number Diff line change @@ -989,6 +989,16 @@ describe('$http', function() {
989
989
} ) ;
990
990
991
991
992
+ it ( 'should ignore Blob objects' , function ( ) {
993
+ if ( ! window . Blob ) return ;
994
+
995
+ var blob = new Blob ( [ 'blob!' ] , { type : 'text/plain' } ) ;
996
+
997
+ $httpBackend . expect ( 'POST' , '/url' , '[object Blob]' ) . respond ( '' ) ;
998
+ $http ( { method : 'POST' , url : '/url' , data : blob } ) ;
999
+ } ) ;
1000
+
1001
+
992
1002
it ( 'should have access to request headers' , function ( ) {
993
1003
$httpBackend . expect ( 'POST' , '/url' , 'header1' ) . respond ( 200 ) ;
994
1004
$http . post ( '/url' , 'req' , {
You can’t perform that action at this time.
0 commit comments