* @ngdoc provider * @name $httpProvider * @description * Use `$httpProvider` to change the default behavior of the ng.$http $http service. *
()
| 10518 | * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. |
| 10519 | * */ |
| 10520 | function $HttpProvider() { |
| 10521 | /** |
| 10522 | * @ngdoc property |
| 10523 | * @name $httpProvider#defaults |
| 10524 | * @description |
| 10525 | * |
| 10526 | * Object containing default values for all {@link ng.$http $http} requests. |
| 10527 | * |
| 10528 | * - **`defaults.cache`** - {Object} - an object built with {@link ng.$cacheFactory `$cacheFactory`} |
| 10529 | * that will provide the cache for all requests who set their `cache` property to `true`. |
| 10530 | * If you set the `defaults.cache = false` then only requests that specify their own custom |
| 10531 | * cache object will be cached. See {@link $http#caching $http Caching} for more information. |
| 10532 | * |
| 10533 | * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. |
| 10534 | * Defaults value is `'XSRF-TOKEN'`. |
| 10535 | * |
| 10536 | * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the |
| 10537 | * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. |
| 10538 | * |
| 10539 | * - **`defaults.headers`** - {Object} - Default headers for all $http requests. |
| 10540 | * Refer to {@link ng.$http#setting-http-headers $http} for documentation on |
| 10541 | * setting default headers. |
| 10542 | * - **`defaults.headers.common`** |
| 10543 | * - **`defaults.headers.post`** |
| 10544 | * - **`defaults.headers.put`** |
| 10545 | * - **`defaults.headers.patch`** |
| 10546 | * |
| 10547 | * |
| 10548 | * - **`defaults.paramSerializer`** - `{string|function(Object<string,string>):string}` - A function |
| 10549 | * used to the prepare string representation of request parameters (specified as an object). |
| 10550 | * If specified as string, it is interpreted as a function registered with the {@link auto.$injector $injector}. |
| 10551 | * Defaults to {@link ng.$httpParamSerializer $httpParamSerializer}. |
| 10552 | * |
| 10553 | **/ |
| 10554 | var defaults = this.defaults = { |
| 10555 | // transform incoming response data |
| 10556 | transformResponse: [defaultHttpResponseTransform], |
| 10557 | |
| 10558 | // transform outgoing request data |
| 10559 | transformRequest: [ |
| 10560 | function (d) { |
| 10561 | return isObject(d) && !isFile(d) && !isBlob(d) && !isFormData(d) ? toJson(d) : d; |
| 10562 | } |
| 10563 | ], |
| 10564 | |
| 10565 | // default headers |
| 10566 | headers: { |
| 10567 | common: { |
| 10568 | 'Accept': 'application/json, text/plain, */*' |
| 10569 | }, |
| 10570 | post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 10571 | put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 10572 | patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) |
| 10573 | }, |
| 10574 | |
| 10575 | xsrfCookieName: 'XSRF-TOKEN', |
| 10576 | xsrfHeaderName: 'X-XSRF-TOKEN', |
| 10577 |
nothing calls this directly
no test coverage detected