File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ extension AddParameters on Uri {
19
19
newParameters[key] = value;
20
20
});
21
21
22
- return buildUrlString (paramUrl, newParameters).toUri ();
22
+ String finalUrl = buildUrlString (paramUrl, newParameters);
23
+
24
+ // Preserve the fragment if it exists
25
+ if (fragment.isNotEmpty) {
26
+ finalUrl += '#$fragment ' ;
27
+ }
28
+
29
+ return finalUrl.toUri ();
23
30
}
24
31
}
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ class InterceptedClient extends BaseClient {
293
293
_retryCount += 1 ;
294
294
await Future .delayed (retryPolicy!
295
295
.delayRetryAttemptOnResponse (retryAttempt: _retryCount));
296
- return _attemptRequest (request);
296
+ return _attemptRequest (request, isStream : isStream );
297
297
}
298
298
} on Exception catch (error) {
299
299
if (retryPolicy != null &&
@@ -302,7 +302,7 @@ class InterceptedClient extends BaseClient {
302
302
_retryCount += 1 ;
303
303
await Future .delayed (retryPolicy!
304
304
.delayRetryAttemptOnException (retryAttempt: _retryCount));
305
- return _attemptRequest (request);
305
+ return _attemptRequest (request, isStream : isStream );
306
306
} else {
307
307
rethrow ;
308
308
}
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ abstract class RetryPolicy {
45
45
FutureOr <bool > shouldAttemptRetryOnResponse (BaseResponse response) => false ;
46
46
47
47
/// Number of maximum request attempts that can be retried.
48
- final int maxRetryAttempts = 1 ;
48
+ int get maxRetryAttempts => 1 ;
49
49
50
50
Duration delayRetryAttemptOnException ({required int retryAttempt}) =>
51
51
Duration .zero;
Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ main() {
12
12
test ("defaults to 1" , () {
13
13
expect (testObject.maxRetryAttempts, 1 );
14
14
});
15
+
16
+ test ("can be overridden" , () {
17
+ testObject = TestRetryPolicy (
18
+ maxRetryAttempts: 5 ,
19
+ );
20
+
21
+ expect (testObject.maxRetryAttempts, 5 );
22
+ });
15
23
});
16
24
17
25
group ("delayRetryAttemptOnException" , () {
@@ -60,4 +68,13 @@ main() {
60
68
});
61
69
}
62
70
63
- class TestRetryPolicy extends RetryPolicy {}
71
+ class TestRetryPolicy extends RetryPolicy {
72
+ TestRetryPolicy ({
73
+ int maxRetryAttempts = 1 ,
74
+ }) : internalMaxRetryAttempts = maxRetryAttempts;
75
+
76
+ final int internalMaxRetryAttempts;
77
+
78
+ @override
79
+ int get maxRetryAttempts => internalMaxRetryAttempts;
80
+ }
You can’t perform that action at this time.
0 commit comments