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

Commit 267b217

Browse files
pkozlowski-opensourceIgorMinar
authored andcommitted
fix($http): send GET requests by default
Fixes #5985 Closes #6401
1 parent 2f45133 commit 267b217

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/ng/http.js

+1
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ function $HttpProvider() {
664664
*/
665665
function $http(requestConfig) {
666666
var config = {
667+
method: 'get',
667668
transformRequest: defaults.transformRequest,
668669
transformResponse: defaults.transformResponse
669670
};

test/ng/httpSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ describe('$http', function() {
405405
$http = $h;
406406
}]));
407407

408+
it('should send GET requests if no method specified', inject(function($httpBackend, $http) {
409+
$httpBackend.expect('GET', '/url').respond('');
410+
$http({url: '/url'});
411+
}));
408412

409413
it('should do basic request', inject(function($httpBackend, $http) {
410414
$httpBackend.expect('GET', '/url').respond('');
@@ -1120,6 +1124,16 @@ describe('$http', function() {
11201124
expect(callback.mostRecentCall.args[0]).toBe('content');
11211125
}));
11221126

1127+
it('should cache request when cache is provided and no method specified', function () {
1128+
doFirstCacheRequest();
1129+
1130+
$http({url: '/url', cache: cache}).success(callback);
1131+
$rootScope.$digest();
1132+
1133+
expect(callback).toHaveBeenCalledOnce();
1134+
expect(callback.mostRecentCall.args[0]).toBe('content');
1135+
});
1136+
11231137

11241138
it('should not cache when cache is not provided', function() {
11251139
doFirstCacheRequest();

0 commit comments

Comments
 (0)