* @ngdoc provider * @name $httpProvider * @description * Use `$httpProvider` to change the default behavior of the ng.$http $http service. *
()
| 10240 | * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. |
| 10241 | * */ |
| 10242 | function $HttpProvider() { |
| 10243 | /** |
| 10244 | * @ngdoc property |
| 10245 | * @name $httpProvider#defaults |
| 10246 | * @description |
| 10247 | * |
| 10248 | * Object containing default values for all {@link ng.$http $http} requests. |
| 10249 | * |
| 10250 | * - **`defaults.cache`** - {Object} - an object built with {@link ng.$cacheFactory `$cacheFactory`} |
| 10251 | * that will provide the cache for all requests who set their `cache` property to `true`. |
| 10252 | * If you set the `defaults.cache = false` then only requests that specify their own custom |
| 10253 | * cache object will be cached. See {@link $http#caching $http Caching} for more information. |
| 10254 | * |
| 10255 | * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. |
| 10256 | * Defaults value is `'XSRF-TOKEN'`. |
| 10257 | * |
| 10258 | * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the |
| 10259 | * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. |
| 10260 | * |
| 10261 | * - **`defaults.headers`** - {Object} - Default headers for all $http requests. |
| 10262 | * Refer to {@link ng.$http#setting-http-headers $http} for documentation on |
| 10263 | * setting default headers. |
| 10264 | * - **`defaults.headers.common`** |
| 10265 | * - **`defaults.headers.post`** |
| 10266 | * - **`defaults.headers.put`** |
| 10267 | * - **`defaults.headers.patch`** |
| 10268 | * |
| 10269 | * |
| 10270 | * - **`defaults.paramSerializer`** - `{string|function(Object<string,string>):string}` - A function |
| 10271 | * used to the prepare string representation of request parameters (specified as an object). |
| 10272 | * If specified as string, it is interpreted as a function registered with the {@link auto.$injector $injector}. |
| 10273 | * Defaults to {@link ng.$httpParamSerializer $httpParamSerializer}. |
| 10274 | * |
| 10275 | **/ |
| 10276 | var defaults = this.defaults = { |
| 10277 | // transform incoming response data |
| 10278 | transformResponse: [defaultHttpResponseTransform], |
| 10279 | |
| 10280 | // transform outgoing request data |
| 10281 | transformRequest: [function(d) { |
| 10282 | return isObject(d) && !isFile(d) && !isBlob(d) && !isFormData(d) ? toJson(d) : d; |
| 10283 | }], |
| 10284 | |
| 10285 | // default headers |
| 10286 | headers: { |
| 10287 | common: { |
| 10288 | 'Accept': 'application/json, text/plain, */*' |
| 10289 | }, |
| 10290 | post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 10291 | put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), |
| 10292 | patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) |
| 10293 | }, |
| 10294 | |
| 10295 | xsrfCookieName: 'XSRF-TOKEN', |
| 10296 | xsrfHeaderName: 'X-XSRF-TOKEN', |
| 10297 | |
| 10298 | paramSerializer: '$httpParamSerializer' |
| 10299 | }; |
nothing calls this directly
no test coverage detected