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

Commit 29541e7

Browse files
committed
revert($resource): support custom headers per action
This reverts commit b936e52. This commit introduces a feature and should haven't been merged into the stable branch.
1 parent f5b567d commit 29541e7

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/ngResource/resource.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
* @param {Object.<Object>=} actions Hash with declaration of custom action that should extend the
3737
* default set of resource actions. The declaration should be created in the following format:
3838
*
39-
* {action1: {method:?, params:?, isArray:?, headers:?},
40-
* action2: {method:?, params:?, isArray:?, headers:?},
39+
* {action1: {method:?, params:?, isArray:?},
40+
* action2: {method:?, params:?, isArray:?},
4141
* ...}
4242
*
4343
* Where:
@@ -49,7 +49,6 @@
4949
* - `params` – {object=} – Optional set of pre-bound parameters for this action.
5050
* - isArray – {boolean=} – If true then the returned object for this action is an array, see
5151
* `returns` section.
52-
* - `headers` – {object=} – Optional HTTP headers to send
5352
*
5453
* @returns {Object} A resource "class" object with methods for the default set of resource actions
5554
* optionally extended with custom `actions`. The default set contains these actions:
@@ -131,7 +130,7 @@
131130
* The object returned from this function execution is a resource "class" which has "static" method
132131
* for each action in the definition.
133132
*
134-
* Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and `headers`.
133+
* Calling these methods invoke `$http` on the `url` template with the given `method` and `params`.
135134
* When the data is returned from the server then the object is an instance of the resource type and
136135
* all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
137136
* operations (create, read, update, delete) on server-side data.
@@ -370,8 +369,7 @@ angular.module('ngResource', ['ng']).
370369
$http({
371370
method: action.method,
372371
url: route.url(extend({}, extractParams(data, action.params || {}), params)),
373-
data: data,
374-
headers: extend({}, action.headers || {})
372+
data: data
375373
}).then(function(response) {
376374
var data = response.data;
377375

test/ngResource/resourceSpec.js

-16
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ describe("resource", function() {
1414
},
1515
patch: {
1616
method: 'PATCH'
17-
},
18-
conditionalPut: {
19-
method: 'PUT',
20-
headers: {
21-
'If-None-Match': '*'
22-
}
2317
}
24-
2518
});
2619
callback = jasmine.createSpy();
2720
}));
@@ -184,15 +177,6 @@ describe("resource", function() {
184177
});
185178

186179

187-
it('should send correct headers', function() {
188-
$httpBackend.expectPUT('/CreditCard/123', undefined, function(headers) {
189-
return headers['If-None-Match'] == "*";
190-
}).respond({id:123});
191-
192-
CreditCard.conditionalPut({id: {key:123}});
193-
});
194-
195-
196180
it("should read partial resource", function() {
197181
$httpBackend.expect('GET', '/CreditCard').respond([{id:{key:123}}]);
198182
var ccs = CreditCard.query();

0 commit comments

Comments
 (0)