Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 00cac6e

Browse files
MikeMcElroyIgorMinar
authored andcommitted
docs($http): makes clear $httpProvider.defaults are available at run-time
Clarifies some confusion around $http.defaults existing and able to be modified at run-time, for when run-time services may be needed in a transformation. Closes #5559 Closes #5630
1 parent 2e9d7cc commit 00cac6e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/ng/http.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,15 @@ function $HttpProvider() {
291291
* `$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }.
292292
*
293293
* The defaults can also be set at runtime via the `$http.defaults` object in the same
294-
* fashion. In addition, you can supply a `headers` property in the config object passed when
294+
* fashion. For example:
295+
*
296+
* ```
297+
* module.run(function($http) {
298+
* $http.defaults.headers.common.Authentication = 'Basic YmVlcDpib29w'
299+
* });
300+
* ```
301+
*
302+
* In addition, you can supply a `headers` property in the config object passed when
295303
* calling `$http(config)`, which overrides the defaults without changing them globally.
296304
*
297305
*
@@ -315,7 +323,9 @@ function $HttpProvider() {
315323
* properties. These properties are by default an array of transform functions, which allows you
316324
* to `push` or `unshift` a new transformation function into the transformation chain. You can
317325
* also decide to completely override any default transformations by assigning your
318-
* transformation functions to these properties directly without the array wrapper.
326+
* transformation functions to these properties directly without the array wrapper. These defaults
327+
* are again available on the $http factory at run-time, which may be useful if you have run-time
328+
* services you wish to be involved in your transformations.
319329
*
320330
* Similarly, to locally override the request/response transforms, augment the
321331
* `transformRequest` and/or `transformResponse` properties of the configuration object passed
@@ -529,7 +539,8 @@ function $HttpProvider() {
529539
* for added security.
530540
*
531541
* The name of the headers can be specified using the xsrfHeaderName and xsrfCookieName
532-
* properties of either $httpProvider.defaults, or the per-request config object.
542+
* properties of either $httpProvider.defaults at config-time, $http.defaults at run-time,
543+
* or the per-request config object.
533544
*
534545
*
535546
* @param {object} config Object describing the request to be made and how it should be

0 commit comments

Comments
 (0)