Http Headers

By default, the AngularJS framework adds some HTTP headers to all of the requests, and other headers only to the POST and PUT methods. The headers are shown in the following code, and we can check them out by analyzing the $http.defaults.headers configuration object:
{
"common":{"Accept":"application/json, text/plain, */*"},
"post":{"Content-Type":"application/json;charset=utf-8"},
"put":{"Content-Type":"application/json;charset=utf-8"},
"patch":{"Content-Type":"application/json;charset=utf-8"}
}
In case you want to add a specific header or even change the defaults, you can use the run function of the Module API, which is used in initializing the application:

run.js
parking.run(function ($http) {
$http.defaults.headers.common.Accept = "application/json";
});

After the header configuration, the request starts to send the custom header:
GET /cars HTTP/1.1
Host: localhost:3412
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:29.0)
Accept: application/json
Accept-Language: pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate

The headers can also be configured through the configuration object of each request. It will overwrite the default headers configured here.
Related Tutorial
2. ajax
5. Caching
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 # # # # #