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 @@ -886,7 +886,8 @@ function $HttpProvider() {
886
886
promise . then ( removePendingReq , removePendingReq ) ;
887
887
888
888
889
- if ( ( config . cache || defaults . cache ) && config . cache !== false && config . method == 'GET' ) {
889
+ if ( ( config . cache || defaults . cache ) && config . cache !== false &&
890
+ ( config . method === 'GET' || config . method === 'JSONP' ) ) {
890
891
cache = isObject ( config . cache ) ? config . cache
891
892
: isObject ( defaults . cache ) ? defaults . cache
892
893
: defaultCache ;
Original file line number Diff line number Diff line change @@ -1106,6 +1106,18 @@ describe('$http', function() {
1106
1106
expect ( callback . mostRecentCall . args [ 0 ] ) . toBe ( 'content' ) ;
1107
1107
} ) ) ;
1108
1108
1109
+ it ( 'should cache JSONP request when cache is provided' , inject ( function ( $rootScope ) {
1110
+ $httpBackend . expect ( 'JSONP' , '/url?cb=JSON_CALLBACK' ) . respond ( 'content' ) ;
1111
+ $http ( { method : 'JSONP' , url : '/url?cb=JSON_CALLBACK' , cache : cache } ) ;
1112
+ $httpBackend . flush ( ) ;
1113
+
1114
+ $http ( { method : 'JSONP' , url : '/url?cb=JSON_CALLBACK' , cache : cache } ) . success ( callback ) ;
1115
+ $rootScope . $digest ( ) ;
1116
+
1117
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1118
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toBe ( 'content' ) ;
1119
+ } ) ) ;
1120
+
1109
1121
it ( 'should cache request when cache is provided and no method specified' , function ( ) {
1110
1122
doFirstCacheRequest ( ) ;
1111
1123
You can’t perform that action at this time.
0 commit comments