This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 4 files changed +17
-1
lines changed
4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 51
51
"isWindow" : false ,
52
52
"isScope" : false ,
53
53
"isFile" : false ,
54
+ "isFormData" : false ,
54
55
"isBlob" : false ,
55
56
"isBoolean" : false ,
56
57
"isPromiseLike" : false ,
Original file line number Diff line number Diff line change 45
45
isWindow: true,
46
46
isScope: true,
47
47
isFile: true,
48
+ isFormData: true,
48
49
isBlob: true,
49
50
isBoolean: true,
50
51
isPromiseLike: true,
@@ -566,6 +567,11 @@ function isFile(obj) {
566
567
}
567
568
568
569
570
+ function isFormData ( obj ) {
571
+ return toString . call ( obj ) === '[object FormData]' ;
572
+ }
573
+
574
+
569
575
function isBlob ( obj ) {
570
576
return toString . call ( obj ) === '[object Blob]' ;
571
577
}
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ function $HttpProvider() {
142
142
143
143
// transform outgoing request data
144
144
transformRequest : [ function ( d ) {
145
- return isObject ( d ) && ! isFile ( d ) && ! isBlob ( d ) ? toJson ( d ) : d ;
145
+ return isObject ( d ) && ! isFile ( d ) && ! isBlob ( d ) && ! isFormData ( d ) ? toJson ( d ) : d ;
146
146
} ] ,
147
147
148
148
// default headers
Original file line number Diff line number Diff line change @@ -991,6 +991,15 @@ describe('$http', function() {
991
991
$http ( { method : 'POST' , url : '/url' , data : blob } ) ;
992
992
} ) ;
993
993
994
+ it ( 'should ignore FormData objects' , function ( ) {
995
+ if ( ! window . FormData ) return ;
996
+
997
+ var formData = new FormData ( ) ;
998
+ formData . append ( 'angular' , 'is great' ) ;
999
+
1000
+ $httpBackend . expect ( 'POST' , '/url' , '[object FormData]' ) . respond ( '' ) ;
1001
+ $http ( { method : 'POST' , url : '/url' , data : formData } ) ;
1002
+ } ) ;
994
1003
995
1004
it ( 'should have access to request headers' , function ( ) {
996
1005
$httpBackend . expect ( 'POST' , '/url' , 'header1' ) . respond ( 200 ) ;
You can’t perform that action at this time.
0 commit comments