* @ngdoc provider * @name $httpProvider * @description * Use `$httpProvider` to change the default behavior of the ng.$http $http service. *
()
| 7415 | * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. |
| 7416 | * */ |
| 7417 | function $HttpProvider() { |
| 7418 | var JSON_START = /^\s*(\[|\{[^\{])/, |
| 7419 | JSON_END = /[\}\]]\s*$/, |
| 7420 | PROTECTION_PREFIX = /^\)\]\}',?\n/, |
| 7421 | CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'}; |
| 7422 | |
| 7423 | /** |
| 7424 | * @ngdoc property |
| 7425 | * @name $httpProvider#defaults |
| 7426 | * @description |
| 7427 | * |
| 7428 | * Object containing default values for all {@link ng.$http $http} requests. |
| 7429 | * |
| 7430 | * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. |
| 7431 | * Defaults value is `'XSRF-TOKEN'`. |
| 7432 | * |
| 7433 | * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the |
| 7434 | * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. |
| 7435 | * |
| 7436 | * - **`defaults.headers`** - {Object} - Default headers for all $http requests. |
| 7437 | * Refer to {@link ng.$http#setting-http-headers $http} for documentation on |
| 7438 | * setting default headers. |
| 7439 | * - **`defaults.headers.common`** |
| 7440 | * - **`defaults.headers.post`** |
| 7441 | * - **`defaults.headers.put`** |
| 7442 | * - **`defaults.headers.patch`** |
| 7443 | **/ |
| 7444 | var defaults = this.defaults = { |
| 7445 | // transform incoming response data |
| 7446 | transformResponse: [function(data) { |
| 7447 | if (isString(data)) { |
| 7448 | // strip json vulnerability protection prefix |
| 7449 | data = data.replace(PROTECTION_PREFIX, ''); |
| 7450 | if (JSON_START.test(data) && JSON_END.test(data)) |
| 7451 | data = fromJson(data); |
| 7452 | } |
| 7453 | return data; |
| 7454 | }], |
| 7455 | |
| 7456 | // transform outgoing request data |
| 7457 | transformRequest: [function(d) { |
| 7458 | return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; |
| 7459 | }], |
| 7460 | |
| 7461 | // default headers |
| 7462 | headers: { |
| 7463 | common: { |
| 7464 | 'Accept': 'application/json, text/plain, */*' |
| 7465 | }, |
| 7466 | post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7467 | put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7468 | patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) |
| 7469 | }, |
| 7470 | |
| 7471 | xsrfCookieName: 'XSRF-TOKEN', |
| 7472 | xsrfHeaderName: 'X-XSRF-TOKEN' |
| 7473 | }; |
| 7474 |
nothing calls this directly
no test coverage detected