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