This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 5151 "isWindow" : false ,
5252 "isScope" : false ,
5353 "isFile" : false ,
54+ "isFormData" : false ,
5455 "isBlob" : false ,
5556 "isBoolean" : false ,
5657 "isPromiseLike" : false ,
Original file line number Diff line number Diff line change 4545 isWindow: true,
4646 isScope: true,
4747 isFile: true,
48+ isFormData: true,
4849 isBlob: true,
4950 isBoolean: true,
5051 isPromiseLike: true,
@@ -566,6 +567,11 @@ function isFile(obj) {
566567}
567568
568569
570+ function isFormData ( obj ) {
571+ return toString . call ( obj ) === '[object FormData]' ;
572+ }
573+
574+
569575function isBlob ( obj ) {
570576 return toString . call ( obj ) === '[object Blob]' ;
571577}
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ function $HttpProvider() {
142142
143143 // transform outgoing request data
144144 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 ;
146146 } ] ,
147147
148148 // default headers
Original file line number Diff line number Diff line change @@ -991,6 +991,15 @@ describe('$http', function() {
991991 $http ( { method : 'POST' , url : '/url' , data : blob } ) ;
992992 } ) ;
993993
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+ } ) ;
9941003
9951004 it ( 'should have access to request headers' , function ( ) {
9961005 $httpBackend . expect ( 'POST' , '/url' , 'header1' ) . respond ( 200 ) ;
You can’t perform that action at this time.
0 commit comments