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

Commit b28b5ca

Browse files
cironunesmgol
authored andcommitted
fix($http): add the PATCH shortcut back
The shortcut was dropped because it had a lot of unkowns about PATCH. Since we already know that using PATCH is good (http://www.mnot.net/blog/2012/09/05/patch), and only IE8 has issues with that, let's add the shortcut back. Closes #5894
1 parent 26c20b7 commit b28b5ca

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/ng/http.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,21 @@ function $HttpProvider() {
790790
* @param {Object=} config Optional configuration object
791791
* @returns {HttpPromise} Future object
792792
*/
793-
createShortMethodsWithData('post', 'put');
793+
794+
/**
795+
* @ngdoc method
796+
* @name ng.$http#patch
797+
* @methodOf ng.$http
798+
*
799+
* @description
800+
* Shortcut method to perform `PATCH` request.
801+
*
802+
* @param {string} url Relative or absolute URL specifying the destination of the request
803+
* @param {*} data Request content
804+
* @param {Object=} config Optional configuration object
805+
* @returns {HttpPromise} Future object
806+
*/
807+
createShortMethodsWithData('post', 'put', 'patch');
794808

795809
/**
796810
* @ngdoc property

test/ng/httpSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ describe('$http', function() {
830830
$http.put('/url', 'some-data', {headers: {'Custom': 'Header'}});
831831
});
832832

833+
it('should have patch()', function(){
834+
$httpBackend.expect('PATCH', '/url', 'some-data').respond('');
835+
$http.patch('/url', 'some-data');
836+
});
837+
838+
it('patch() should allow config param', function() {
839+
$httpBackend.expect('PATCH', '/url', 'some-data', checkHeader('Custom', 'Header')).respond('');
840+
$http.patch('/url', 'some-data', {headers: {'Custom': 'Header'}});
841+
});
833842

834843
it('should have jsonp()', function() {
835844
$httpBackend.expect('JSONP', '/url').respond('');

0 commit comments

Comments
 (0)