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

Commit bd9e894

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

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
@@ -317,6 +317,21 @@ function $HttpProvider() {
317317
* In addition, you can supply a `headers` property in the config object passed when
318318
* calling `$http(config)`, which overrides the defaults without changing them globally.
319319
*
320+
* To explicitly remove a header automatically added via $httpProvider.defaults.headers on a per request basis,
321+
* Use the `headers` property, setting the desired header to `undefined`. For example:
322+
*
323+
* ```
324+
* var req = {
325+
* method: 'POST',
326+
* url: 'http://example.com',
327+
* headers: {
328+
* 'Content-Type': undefined
329+
* },
330+
* data: { test: 'test' },
331+
* }
332+
*
333+
* $http(req).success(function(){...}).error(function(){...});
334+
* ```
320335
*
321336
* # Transforming Requests and Responses
322337
*

0 commit comments

Comments
 (0)