@@ -17,7 +17,6 @@ import 'base_client.dart';
17
17
import 'base_request.dart' ;
18
18
import 'exception.dart' ;
19
19
import 'streamed_response.dart' ;
20
- import 'utils.dart' ;
21
20
22
21
/// Create a [BrowserClient] .
23
22
///
@@ -45,9 +44,17 @@ BaseClient createClient() {
45
44
class BrowserClient extends BaseClient {
46
45
final _abortController = AbortController ();
47
46
48
- BrowserClient ([CacheOption ? cacheOption]) {
49
- _cacheOption = cacheOption? .cacheType ?? CacheOption .defaultType.cacheType;
50
- }
47
+ /// Create a new browser-based HTTP Client.
48
+ ///
49
+ /// If [cacheMode] is provided then it can be used to cache the request
50
+ /// in the browser.
51
+ ///
52
+ /// For example:
53
+ /// ```dart
54
+ /// const mode = 'reload';
55
+ /// final client = BrowserClient(cacheMode: mode);
56
+ /// ```
57
+ BrowserClient ({this .cacheMode = 'default' });
51
58
52
59
/// Whether to send credentials such as cookies or authorization headers for
53
60
/// cross-site requests.
@@ -57,7 +64,10 @@ class BrowserClient extends BaseClient {
57
64
58
65
bool _isClosed = false ;
59
66
60
- String ? _cacheOption;
67
+ /// Use different caching mode for a HTTP request.
68
+ /// Defaults to `default` .
69
+ // https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
70
+ String cacheMode;
61
71
62
72
/// Sends an HTTP request and asynchronously returns the response.
63
73
@override
@@ -75,7 +85,7 @@ class BrowserClient extends BaseClient {
75
85
RequestInit (
76
86
method: request.method,
77
87
body: bodyBytes.isNotEmpty ? bodyBytes.toJS : null ,
78
- cache: _cacheOption ! ,
88
+ cache: cacheMode ,
79
89
credentials: withCredentials ? 'include' : 'same-origin' ,
80
90
headers: {
81
91
if (request.contentLength case final contentLength? )
0 commit comments