This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,10 @@ function isFile(obj) {
565
565
return toString . call ( obj ) === '[object File]' ;
566
566
}
567
567
568
+ function isFormData ( obj ) {
569
+ return toString . call ( obj ) === '[object FormData]' ;
570
+ }
571
+
568
572
569
573
function isBlob ( obj ) {
570
574
return toString . call ( obj ) === '[object Blob]' ;
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 . Blob ) 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