File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -705,10 +705,6 @@ function $HttpProvider() {
705
705
706
706
defHeaders = extend ( { } , defHeaders . common , defHeaders [ lowercase ( config . method ) ] ) ;
707
707
708
- // execute if header value is function
709
- execHeaders ( defHeaders ) ;
710
- execHeaders ( reqHeaders ) ;
711
-
712
708
// using for-in instead of forEach to avoid unecessary iteration after header has been found
713
709
defaultHeadersIteration:
714
710
for ( defHeaderName in defHeaders ) {
@@ -723,6 +719,8 @@ function $HttpProvider() {
723
719
reqHeaders [ defHeaderName ] = defHeaders [ defHeaderName ] ;
724
720
}
725
721
722
+ // execute if header value is a function for merged headers
723
+ execHeaders ( reqHeaders ) ;
726
724
return reqHeaders ;
727
725
728
726
function execHeaders ( headers ) {
Original file line number Diff line number Diff line change @@ -652,6 +652,18 @@ describe('$http', function() {
652
652
$httpBackend . flush ( ) ;
653
653
} ) ;
654
654
655
+ it ( 'should delete default headers if custom header function returns null' , function ( ) {
656
+
657
+ $httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
658
+ return ! ( 'Accept' in headers ) ;
659
+ } ) . respond ( '' ) ;
660
+
661
+ $http ( { url : '/url' , method : 'POST' , data : 'messageBody' , headers : {
662
+ 'Accept' : function ( ) { return null ; }
663
+ } } ) ;
664
+ $httpBackend . flush ( ) ;
665
+ } ) ;
666
+
655
667
it ( 'should override default headers with custom in a case insensitive manner' , function ( ) {
656
668
$httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
657
669
return headers [ 'accept' ] == 'Rewritten' &&
You can’t perform that action at this time.
0 commit comments