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

fix(http): send GET requests by default #6401

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ng/http.js
Original file line number Diff line number Diff line change
@@ -664,6 +664,7 @@ function $HttpProvider() {
*/
function $http(requestConfig) {
var config = {
method: 'get',
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
};
14 changes: 14 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
@@ -405,6 +405,10 @@ describe('$http', function() {
$http = $h;
}]));

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

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

it('should cache request when cache is provided and no method specified', function () {
doFirstCacheRequest();

$http({url: '/url', cache: cache}).success(callback);
$rootScope.$digest();

expect(callback).toHaveBeenCalledOnce();
expect(callback.mostRecentCall.args[0]).toBe('content');
});


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