This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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 @@ -777,10 +777,6 @@ function $HttpProvider() {
777
777
778
778
defHeaders = extend ( { } , defHeaders . common , defHeaders [ lowercase ( config . method ) ] ) ;
779
779
780
- // execute if header value is function
781
- execHeaders ( defHeaders ) ;
782
- execHeaders ( reqHeaders ) ;
783
-
784
780
// using for-in instead of forEach to avoid unecessary iteration after header has been found
785
781
defaultHeadersIteration:
786
782
for ( defHeaderName in defHeaders ) {
@@ -795,6 +791,8 @@ function $HttpProvider() {
795
791
reqHeaders [ defHeaderName ] = defHeaders [ defHeaderName ] ;
796
792
}
797
793
794
+ // execute if header value is a function for merged headers
795
+ execHeaders ( reqHeaders ) ;
798
796
return reqHeaders ;
799
797
800
798
function execHeaders ( headers ) {
Original file line number Diff line number Diff line change @@ -772,6 +772,18 @@ describe('$http', function() {
772
772
$httpBackend . flush ( ) ;
773
773
} ) ;
774
774
775
+ it ( 'should delete default headers if custom header function returns null' , function ( ) {
776
+
777
+ $httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
778
+ return ! ( 'Accept' in headers ) ;
779
+ } ) . respond ( '' ) ;
780
+
781
+ $http ( { url : '/url' , method : 'POST' , data : 'messageBody' , headers : {
782
+ 'Accept' : function ( ) { return null ; }
783
+ } } ) ;
784
+ $httpBackend . flush ( ) ;
785
+ } ) ;
786
+
775
787
it ( 'should override default headers with custom in a case insensitive manner' , function ( ) {
776
788
$httpBackend . expect ( 'POST' , '/url' , 'messageBody' , function ( headers ) {
777
789
return headers [ 'accept' ] == 'Rewritten' &&
You can’t perform that action at this time.
0 commit comments