File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,9 @@ class Http {
415
415
* - xsrfHeaderName: TBI
416
416
* - xsrfCookieName: TBI
417
417
* - interceptors: Either a [HttpInterceptor] or a [HttpInterceptors]
418
- * - cache: Boolean or [Cache] . If true, the default cache will be used.
418
+ * - cache: Boolean or [Cache] . If true or not specified at all, the default cache will be used.
419
+ * If false, no cache will be used. If object of type [Cache] is provided, that object will
420
+ * be used as cache.
419
421
* - timeout: deprecated
420
422
*/
421
423
async .Future <HttpResponse > call ({
@@ -468,7 +470,7 @@ class Http {
468
470
469
471
if (cache == false ) {
470
472
cache = null ;
471
- } else if (cache == null ) {
473
+ } else if (cache == true || cache == null ) {
472
474
cache = defaults.cache;
473
475
}
474
476
Original file line number Diff line number Diff line change @@ -838,6 +838,22 @@ void main() {
838
838
http (method: 'GET' , url: '/url' , cache: false );
839
839
flush ();
840
840
}));
841
+
842
+ it ('should use default cache if {cache: true} is passed in request config' , async (() {
843
+ http.defaults.cache = cache;
844
+
845
+ // Fill default cache.
846
+ backend.expect ('GET' , '/url' ).respond (200 , 'content-cache' );
847
+ http (method: 'GET' , url: '/url' , cache: true );
848
+ flush ();
849
+
850
+ // Serve request from default cache when {cache: true} is set.
851
+ http (method: 'GET' , url: '/url' , cache: true ).then (callback);
852
+ microLeap ();
853
+
854
+ expect (callback).toHaveBeenCalledOnce ();
855
+ expect (callback.mostRecentCall.positionalArguments[0 ].data).toEqual ('content-cache' );
856
+ }));
841
857
});
842
858
});
843
859
You can’t perform that action at this time.
0 commit comments