File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -415,7 +415,8 @@ 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, the default cache will be used. If false, no cache will
419
+ * be used. If object of type [Cache] is provided, that object will be used as cache.
419
420
* - timeout: deprecated
420
421
*/
421
422
async .Future <HttpResponse > call ({
@@ -468,7 +469,7 @@ class Http {
468
469
469
470
if (cache == false ) {
470
471
cache = null ;
471
- } else if (cache == null ) {
472
+ } else if (cache == true ) {
472
473
cache = defaults.cache;
473
474
}
474
475
Original file line number Diff line number Diff line change @@ -838,6 +838,21 @@ 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
+ backend.expect ('GET' , '/url' ).respond (200 , 'content-cache' );
846
+ http (method: 'GET' , url: '/url' );
847
+ flush ();
848
+
849
+ backend.expect ('GET' , '/url' ).respond ();
850
+ http (method: 'GET' , url: '/url' , cache: true ).then (callback);
851
+ flush ();
852
+
853
+ expect (callback).toHaveBeenCalledOnce ();
854
+ expect (callback.mostRecentCall.positionalArguments[0 ].data).toEqual ('content-cache' );
855
+ }));
841
856
});
842
857
});
843
858
You can’t perform that action at this time.
0 commit comments