$routeProvider is a provider, but on the other hand $http is an instance, so basically you cannot inject an instace to config block where you set $routeProvider, but you can inject $http instance to run block which suits you most...
ok let's deal the problem you face, actually you can do it any controller you want but you want it to do when only location/route changes so let's inject another instance $rootScope to run block to watch location/route changes...
but you have one more request set $http.defaults depends on $location.path() so let's inject another instance $location to run block to get current path...
so here is our final run block
app.run(function($rootScope, $http, $location) {
$rootScope.$on('$locationChangeSuccess', function(event, next, current) {
$http.defaults.headers.common.HeaderName = $location.path();
console.log("Headers :",$http.defaults.headers);
});
});
from now on after every location change trigger our watch where we set $http.headers depends on $location.path()...
here is working PLUNKER
UPDATE
if you want to look other $route and $location events check this PLUNKER
{headers: {'headerName': 'headerValue'}to each request manually. But I'm looking for the way to do it once. Please, explain the solution you offered (based on fact that services are singletons)?