This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -886,7 +886,8 @@ function $HttpProvider() {
886886 promise . then ( removePendingReq , removePendingReq ) ;
887887
888888
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' ) ) {
890891 cache = isObject ( config . cache ) ? config . cache
891892 : isObject ( defaults . cache ) ? defaults . cache
892893 : defaultCache ;
Original file line number Diff line number Diff line change @@ -1106,6 +1106,18 @@ describe('$http', function() {
11061106 expect ( callback . mostRecentCall . args [ 0 ] ) . toBe ( 'content' ) ;
11071107 } ) ) ;
11081108
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+
11091121 it ( 'should cache request when cache is provided and no method specified' , function ( ) {
11101122 doFirstCacheRequest ( ) ;
11111123
You can’t perform that action at this time.
0 commit comments