@@ -284,6 +284,27 @@ describe('$http', function() {
284
284
} ) ;
285
285
} ) ;
286
286
287
+
288
+ it ( 'should allow replacement of the headers object' , function ( ) {
289
+ module ( function ( $httpProvider ) {
290
+ $httpProvider . interceptors . push ( function ( ) {
291
+ return {
292
+ request : function ( config ) {
293
+ config . headers = { foo : 'intercepted' } ;
294
+ return config ;
295
+ }
296
+ } ;
297
+ } ) ;
298
+ } ) ;
299
+ inject ( function ( $http , $httpBackend , $rootScope ) {
300
+ $httpBackend . expect ( 'GET' , '/url' , null , function ( headers ) {
301
+ return angular . equals ( headers , { foo : 'intercepted' } ) ;
302
+ } ) . respond ( '' ) ;
303
+ $http . get ( '/url' ) ;
304
+ $rootScope . $apply ( ) ;
305
+ } ) ;
306
+ } ) ;
307
+
287
308
it ( 'should reject the http promise if an interceptor fails' , function ( ) {
288
309
var reason = new Error ( 'interceptor failed' ) ;
289
310
module ( function ( $httpProvider ) {
@@ -752,7 +773,7 @@ describe('$http', function() {
752
773
$httpBackend . expect ( 'POST' , '/url2' , undefined , function ( headers ) {
753
774
return ! headers . hasOwnProperty ( 'content-type' ) ;
754
775
} ) . respond ( '' ) ;
755
-
776
+
756
777
$http ( { url : '/url' , method : 'POST' } ) ;
757
778
$http ( { url : '/url2' , method : 'POST' , headers : { 'content-type' : 'Rewritten' } } ) ;
758
779
$httpBackend . flush ( ) ;
0 commit comments