This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -945,7 +945,8 @@ function $HttpProvider() {
945
945
promise . then ( removePendingReq , removePendingReq ) ;
946
946
947
947
948
- if ( ( config . cache || defaults . cache ) && config . cache !== false && config . method == 'GET' ) {
948
+ if ( ( config . cache || defaults . cache ) && config . cache !== false &&
949
+ ( config . method === 'GET' || config . method === 'JSONP' ) ) {
949
950
cache = isObject ( config . cache ) ? config . cache
950
951
: isObject ( defaults . cache ) ? defaults . cache
951
952
: defaultCache ;
Original file line number Diff line number Diff line change @@ -1217,6 +1217,18 @@ describe('$http', function() {
1217
1217
expect ( callback . mostRecentCall . args [ 0 ] ) . toBe ( 'content' ) ;
1218
1218
} ) ) ;
1219
1219
1220
+ it ( 'should cache JSONP request when cache is provided' , inject ( function ( $rootScope ) {
1221
+ $httpBackend . expect ( 'JSONP' , '/url?cb=JSON_CALLBACK' ) . respond ( 'content' ) ;
1222
+ $http ( { method : 'JSONP' , url : '/url?cb=JSON_CALLBACK' , cache : cache } ) ;
1223
+ $httpBackend . flush ( ) ;
1224
+
1225
+ $http ( { method : 'JSONP' , url : '/url?cb=JSON_CALLBACK' , cache : cache } ) . success ( callback ) ;
1226
+ $rootScope . $digest ( ) ;
1227
+
1228
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1229
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toBe ( 'content' ) ;
1230
+ } ) ) ;
1231
+
1220
1232
it ( 'should cache request when cache is provided and no method specified' , function ( ) {
1221
1233
doFirstCacheRequest ( ) ;
1222
1234
You can’t perform that action at this time.
0 commit comments