* @ngdoc provider * @name $httpProvider * @description * Use `$httpProvider` to change the default behavior of the ng.$http $http service. *
()
| 7515 | * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. |
| 7516 | * */ |
| 7517 | function $HttpProvider() { |
| 7518 | var JSON_START = /^\s*(\[|\{[^\{])/, |
| 7519 | JSON_END = /[\}\]]\s*$/, |
| 7520 | PROTECTION_PREFIX = /^\)\]\}',?\n/, |
| 7521 | CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'}; |
| 7522 | |
| 7523 | /** |
| 7524 | * @ngdoc property |
| 7525 | * @name $httpProvider#defaults |
| 7526 | * @description |
| 7527 | * |
| 7528 | * Object containing default values for all {@link ng.$http $http} requests. |
| 7529 | * |
| 7530 | * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. |
| 7531 | * Defaults value is `'XSRF-TOKEN'`. |
| 7532 | * |
| 7533 | * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the |
| 7534 | * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. |
| 7535 | * |
| 7536 | * - **`defaults.headers`** - {Object} - Default headers for all $http requests. |
| 7537 | * Refer to {@link ng.$http#setting-http-headers $http} for documentation on |
| 7538 | * setting default headers. |
| 7539 | * - **`defaults.headers.common`** |
| 7540 | * - **`defaults.headers.post`** |
| 7541 | * - **`defaults.headers.put`** |
| 7542 | * - **`defaults.headers.patch`** |
| 7543 | **/ |
| 7544 | var defaults = this.defaults = { |
| 7545 | // transform incoming response data |
| 7546 | transformResponse: [function(data) { |
| 7547 | if (isString(data)) { |
| 7548 | // strip json vulnerability protection prefix |
| 7549 | data = data.replace(PROTECTION_PREFIX, ''); |
| 7550 | if (JSON_START.test(data) && JSON_END.test(data)) |
| 7551 | data = fromJson(data); |
| 7552 | } |
| 7553 | return data; |
| 7554 | }], |
| 7555 | |
| 7556 | // transform outgoing request data |
| 7557 | transformRequest: [function(d) { |
| 7558 | return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; |
| 7559 | }], |
| 7560 | |
| 7561 | // default headers |
| 7562 | headers: { |
| 7563 | common: { |
| 7564 | 'Accept': 'application/json, text/plain, */*' |
| 7565 | }, |
| 7566 | post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7567 | put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7568 | patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) |
| 7569 | }, |
| 7570 | |
| 7571 | xsrfCookieName: 'XSRF-TOKEN', |
| 7572 | xsrfHeaderName: 'X-XSRF-TOKEN' |
| 7573 | }; |
| 7574 |
nothing calls this directly
no test coverage detected