@@ -738,6 +738,32 @@ describe('$http', function() {
738
738
$httpBackend . flush ( ) ;
739
739
} ) ;
740
740
741
+ it ( 'should override default headers with header function' , function ( ) {
742
+ $httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
743
+ return headers [ 'Accept' ] == 'Rewritten' &&
744
+ headers [ 'Content-Type' ] == 'Rewritten' ;
745
+ } ) . respond ( '' ) ;
746
+
747
+ $http ( { url : '/url' , method : 'POST' , data : 'messageBody' , headers : {
748
+ 'Accept' : 'Rewritten' ,
749
+ 'Content-Type' : function ( ) { return 'Rewritten' ; }
750
+ } } ) ;
751
+ $httpBackend . flush ( ) ;
752
+ } ) ;
753
+
754
+ it ( 'should remove default headers with header function' , function ( ) {
755
+ $httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
756
+ return headers [ 'Accept' ] == 'Rewritten' &&
757
+ typeof headers [ 'Content-Type' ] === "undefined" ;
758
+ } ) . respond ( '' ) ;
759
+
760
+ $http ( { url : '/url' , method : 'POST' , data : 'messageBody' , headers : {
761
+ 'Accept' : 'Rewritten' ,
762
+ 'Content-Type' : function ( ) { return null ; }
763
+ } } ) ;
764
+ $httpBackend . flush ( ) ;
765
+ } ) ;
766
+
741
767
it ( 'should override default headers with custom in a case insensitive manner' , function ( ) {
742
768
$httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
743
769
return headers [ 'accept' ] == 'Rewritten' &&
0 commit comments