* @ngdoc provider * @name $httpProvider * @description * Use `$httpProvider` to change the default behavior of the ng.$http $http service. *
()
| 7445 | * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. |
| 7446 | * */ |
| 7447 | function $HttpProvider() { |
| 7448 | var JSON_START = /^\s*(\[|\{[^\{])/, |
| 7449 | JSON_END = /[\}\]]\s*$/, |
| 7450 | PROTECTION_PREFIX = /^\)\]\}',?\n/, |
| 7451 | CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'}; |
| 7452 | |
| 7453 | /** |
| 7454 | * @ngdoc property |
| 7455 | * @name $httpProvider#defaults |
| 7456 | * @description |
| 7457 | * |
| 7458 | * Object containing default values for all {@link ng.$http $http} requests. |
| 7459 | * |
| 7460 | * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. |
| 7461 | * Defaults value is `'XSRF-TOKEN'`. |
| 7462 | * |
| 7463 | * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the |
| 7464 | * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. |
| 7465 | * |
| 7466 | * - **`defaults.headers`** - {Object} - Default headers for all $http requests. |
| 7467 | * Refer to {@link ng.$http#setting-http-headers $http} for documentation on |
| 7468 | * setting default headers. |
| 7469 | * - **`defaults.headers.common`** |
| 7470 | * - **`defaults.headers.post`** |
| 7471 | * - **`defaults.headers.put`** |
| 7472 | * - **`defaults.headers.patch`** |
| 7473 | **/ |
| 7474 | var defaults = this.defaults = { |
| 7475 | // transform incoming response data |
| 7476 | transformResponse: [function(data) { |
| 7477 | if (isString(data)) { |
| 7478 | // strip json vulnerability protection prefix |
| 7479 | data = data.replace(PROTECTION_PREFIX, ''); |
| 7480 | if (JSON_START.test(data) && JSON_END.test(data)) |
| 7481 | data = fromJson(data); |
| 7482 | } |
| 7483 | return data; |
| 7484 | }], |
| 7485 | |
| 7486 | // transform outgoing request data |
| 7487 | transformRequest: [function(d) { |
| 7488 | return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; |
| 7489 | }], |
| 7490 | |
| 7491 | // default headers |
| 7492 | headers: { |
| 7493 | common: { |
| 7494 | 'Accept': 'application/json, text/plain, */*' |
| 7495 | }, |
| 7496 | post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7497 | put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 7498 | patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) |
| 7499 | }, |
| 7500 | |
| 7501 | xsrfCookieName: 'XSRF-TOKEN', |
| 7502 | xsrfHeaderName: 'X-XSRF-TOKEN' |
| 7503 | }; |
| 7504 |
nothing calls this directly
no test coverage detected