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

Commit 5388ca5

Browse files
dustinchilsoncaitp
authored andcommitted
docs($http): describe how to remove a header on a per request basis
Closes #10144
1 parent 1b275fb commit 5388ca5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ng/http.js

+15
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,21 @@ function $HttpProvider() {
349349
* In addition, you can supply a `headers` property in the config object passed when
350350
* calling `$http(config)`, which overrides the defaults without changing them globally.
351351
*
352+
* To explicitly remove a header automatically added via $httpProvider.defaults.headers on a per request basis,
353+
* Use the `headers` property, setting the desired header to `undefined`. For example:
354+
*
355+
* ```
356+
* var req = {
357+
* method: 'POST',
358+
* url: 'http://example.com',
359+
* headers: {
360+
* 'Content-Type': undefined
361+
* },
362+
* data: { test: 'test' },
363+
* }
364+
*
365+
* $http(req).success(function(){...}).error(function(){...});
366+
* ```
352367
*
353368
* ## Transforming Requests and Responses
354369
*

0 commit comments

Comments
 (0)