aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/http.js
diff options
context:
space:
mode:
authorDaniel Stockton2013-05-11 19:23:33 +0300
committerIgor Minar2013-05-16 14:05:05 -0700
commitf9b897de4b5cc438515cbb54519fbdf6242f5858 (patch)
tree4caccb717a93930196a9b862ee93ca84ad5d9d8c /src/ng/http.js
parent1f99c3a521e84902e3021166d8024c8f419e53d2 (diff)
downloadangular.js-f9b897de4b5cc438515cbb54519fbdf6242f5858.tar.bz2
feat($http): add a default content type for PATH requests
The default header is now application/json which while not perfect in all cases is better than the browser default application/xml. The new headers also makes for better compatibility with Rails 4
Diffstat (limited to 'src/ng/http.js')
-rw-r--r--src/ng/http.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ng/http.js b/src/ng/http.js
index a7f3b92d..708a0650 100644
--- a/src/ng/http.js
+++ b/src/ng/http.js
@@ -123,7 +123,8 @@ function isSuccess(status) {
function $HttpProvider() {
var JSON_START = /^\s*(\[|\{[^\{])/,
JSON_END = /[\}\]]\s*$/,
- PROTECTION_PREFIX = /^\)\]\}',?\n/;
+ PROTECTION_PREFIX = /^\)\]\}',?\n/,
+ CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'};
var defaults = this.defaults = {
// transform incoming response data
@@ -147,8 +148,9 @@ function $HttpProvider() {
common: {
'Accept': 'application/json, text/plain, */*'
},
- post: {'Content-Type': 'application/json;charset=utf-8'},
- put: {'Content-Type': 'application/json;charset=utf-8'}
+ post: CONTENT_TYPE_APPLICATION_JSON,
+ put: CONTENT_TYPE_APPLICATION_JSON,
+ patch: CONTENT_TYPE_APPLICATION_JSON
},
xsrfCookieName: 'XSRF-TOKEN',
@@ -340,7 +342,7 @@ function $HttpProvider() {
*
* A custom default cache built with $cacheFactory can be provided in $http.defaults.cache.
* To skip it, set configuration property `cache` to `false`.
- *
+ *
*
* # Interceptors
*
@@ -873,8 +875,8 @@ function $HttpProvider() {
if ((config.cache || defaults.cache) && config.cache !== false && config.method == 'GET') {
- cache = isObject(config.cache) ? config.cache
- : isObject(defaults.cache) ? defaults.cache
+ cache = isObject(config.cache) ? config.cache
+ : isObject(defaults.cache) ? defaults.cache
: defaultCache;
}